< Previous | Front page | Next >
Skip to end of metadata
Go to start of metadata

Location concepts

Page object encapsulates some page. This page has its location. We can see location of a page as some kind of metadata logically related to that page. In order to have this location information wired with page as such, there is @Location annotation by which you can specify where some page is located. Check out this simple example:

The above location value will be treated as the relative URL to the value of @ArquillianResource URL contextRoot - e.g. http://localhost:8080/app/index.html.

Use @Location("") to denote that page object's location equals to the context root of the deployed application.

By putting @Location annotation at page object, when you inject this page annotated with @InitialPage annotation into a test method, that page object will be open at that location as the very first action in a test method. Lets see an example:

Location schemes

Every location has some scheme. In the previous example, there is used HTTP scheme by default. There are multiple schemes as:

HTTP scheme

Treats location as http:// scheme. You do not have to specify scheme paramater since by default it is HTTP

You can not do this

since it is not possible to say if this location is relative (as index.html) or absolute. You have to use http:// scheme string explicitly to open regular www page on the net.

File scheme

Treats location as file:// scheme

Resource scheme

Treats location as resource:// scheme

The "resource://" prefix denotes that the page is not deployed to any container, and will be loaded from local file-system. The same you can achieve with prefix "file".
Check out Graphene Utility Class documentation page, to see how you can use Graphene.goTo(Class<?> pageObjectClass) method to load Page Object location in the browser.

How do I implement my own scheme?

Custom scheme is implemented e.g. in Droidium so you can open your activities as pages. You have to extend org.jboss.arquillian.graphene.spi.location.Scheme and add your own scheme like this:

Then you have to implement your own org.jboss.arquillian.graphene.location.decider.LocationDecider which is in Graphene SPI as well. This decider resolves scheme value which will WebDriver instance subsequently open via get() method.

Finally you have to register this decider as a service in Arquillian's loadable extension.

After that, you can do this:

How to set default scheme per project?

Imaging you are dealing only with Android activities so specifying scheme = DroidiumScheme.class is not needed. You can set default scheme in arquillian.xml like this:

Now you can use it like:

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.