Annotation Type JavaScript
Interfaces or abstract classes annotated with this interface invokes a script on a page under test.
This annotation is used for both, annotating the type and marking the injection point as demonstrated in following example.
The interface can also automatically retrieve JavaScript file dependencies, using Dependency annotation.
Default implementation of ExecutionResolver which invokes the script on the page automatically converts all types
defined by JavascriptExecutor.executeScript(String, Object...) and additionally it converts enumerations to their
string representation.
Default implementation also automatically resolves the getters and setters name as accessors to the object. Java method called setName can either call setName method on target JavaScript object or it can set a value of name property of that object. Similarly getName can either call a getName method or return name property.
The name of a method is automatically diverged from name of a Java interface method, however it can be re-defined using
MethodName annotation.
Example
helloworld.js
window.helloworld = {
hello: function() {
return "Hello World!";
}
}
HelloWorld.java
@JavaScript("helloworld")
@Dependency(sources = "helloworld.js")
public interface HelloWorld {
String hello();
}
TestCase.java
public static class TestCase {
@JavaScript
private HelloWorld helloWorld;
@Test
public void testHelloWorld() {
assertEquals("Hello World!", helloWorld.hello());
}
}
- Author:
- Lukas Fryc
-
Nested Class Summary
Nested Classes -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<? extends ExecutionResolver>ReturnsExecutionResolverwhich will execute the JavaScript interface.Indicates that this interface is just an interface and its implementation (another JavaScript interface) is specified in linked implementation class.The name of JavaScript interface - Graphene will look up the global object of that name on a page.
-
Element Details
-
value
String valueThe name of JavaScript interface - Graphene will look up the global object of that name on a page.
Defaults to window.<type> where type is name of the interface annotated with this annotation.
- Returns:
- name of the interface
- Default:
- ""
-
implementation
String implementationIndicates that this interface is just an interface and its implementation (another JavaScript interface) is specified in linked implementation class.- Returns:
- the class of implementation
- Default:
- ""
-
executionResolver
Class<? extends ExecutionResolver> executionResolverReturnsExecutionResolverwhich will execute the JavaScript interface.- Returns:
- the class of a
ExecutionResolverwhich will invokes this interface
- Default:
- org.jboss.arquillian.graphene.javascript.JavaScript.DefaultExecutionResolver.class
-