Arquillian Graphene extension.
- Allow Page fragments with multiple 'root' elements, like radio button group. See also Testing Radio button group with Arquillian Graphene
- Injecting utility classes which don't have a root but need the WebDriver, like utility class for handling alert's.
- Detecting mechanism to see if the DOM element selected by @FindBy() correspond with the Page Fragment class. Some validation to see if we didn't make any assignment mistakes.
- 1 set of Page Fragments which are capable of testing any Web framework, as long as they generate HTML and CSS. Like, but not limited to, PrimeFaces, AngularPrime, AngularJS, jQuery UI, ...
You can annotate a no argument method with javax.annotation.PostConstruct and this method will then be executed the first time the proxy to the WebElement is accessed.
This can be used to do some initialization, like in the radio button group scenario to detect all radio button belonging to the same group.
See for example be.rubus.web.testing.widget.extension.angularprime.PuiRadiobuttonGroup
You can inject any POJO class into the test class (class with the RunWith(Arquillian.class) annotation) and any enhancement will be performed in this utility class. For example the property with @Drone will be initialized.
You need to annotate the property in the test class with @Graphene.
Another use case for the @Graphene is to inject the GrapheneContext instance into a page fragment. It has some very useful methods like initializePageFragment used in the PuiRadioButtonGroup to initialize Page Fragment's for each radio button.
You can apply the @WidgetValidation annotation to a method which will verify if the Page Fragment root points to a compatible DOM element.
This is very useful to verify the correct assignment of the element id (using @FindBy) to a certain type of DOM element.
The following code will lead maybe to some strange errors
@FindBy("saveBtn") private PuiButton saveButton;
When saveBtn points to textarea for some reason.
2 types of methods are supported :
- No argument method which returns a boolean (return false means the Page fragment can't work with the supplied element in the root.
- No argument method wich return an instance of Detector. This is an interface with one single method which also returns a boolean.
The second type of methods, with the interface, is created to allow a clear separation between the validation code and the real Page Fragment code.
A lot of frameworks, like PrimeFaces, AngularPrime, AngularJS and so on generate HTML, JavaScript and CSS. The HTML DOM structure of a the widget is sometimes very similar.
The idea was then to have one testing framework which handles the HTML generated by these frameworks to maximize the reusability of the Page Fragments.
Of course there will be specific widgets and extensions are foreseen for each framework.
This is version 0.1 of the framework to verify if the concepts could work. Not all widgets of mentioned frameworks are created nor is the code complete for those widgets which are provided.
This will be handled in future versions.
Of course, any feedback on the approach, issues or improvements are welcome of course.