@RunWith(Arquillian.class) @RunAsClient public class MyTest { @Drone private WebDriver browser; @ArquillianResource private JavascriptExecutor executor; @Test public void test() { browser.navigate().to(...); executor.executeAsync(...); } }
Following objects can be injected using @ArquillianResource annotation to:
test case
(a test class containing @Test method when it is marked to @RunWith(Arquillian.class))
Page Objects
Page Fragments
For example:
@RunWith(Arquillian.class) @RunAsClient public class MyTest { @Drone private WebDriver browser; @ArquillianResource private JavascriptExecutor executor; @Test public void test() { browser.navigate().to(...); executor.executeAsync(...); } }
Here is a list of available resources that can be injected:
Class |
Purpose |
WebDriver |
The main interface to use for testing, which represents an idealised web browser. |
Represents the local storage for the site currently opened in the browser. Each site has its own separate storage area. |
|
Represents the session storage in the browser for the site currently opened in the browser. The session storage areas is specific to the current top level browsing context. Each context has a unique set of session storage, one for each origin. Sites can add data to the session storage and it will be accessible to any page from the same site opened in that window. |
|
Represents the application cache status. |
|
Represents basic touch screen operations. |
|
Represents rotation of the browser view for orientation-sensitive devices. When using this with a real device, the device should not be moved so that the built-in sensors do not interfere. |
|
Represents the connection state of the application. |
|
Represents the physical location of the browser. |
|
The user-facing API for emulating complex user gestures. Use this class rather than using the Keyboard or Mouse directly. Implements the builder pattern: Builds a CompositeAction containing all actions specified by the method calls. |
|
Represents basic keyboard operations. |
|
Represents basic mouse operations. |
|
Executes JavaScript, providing access to the mechanism to do so. |
|
Captures a screenshot and store it in different ways. |
|
Describes a series of key/value pairs that encapsulate aspects of a browser. |