Skip to content

rdebusscher/grafaces

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grafaces

Arquillian Graphene extension.

What do I want to solve with this Extension?

  1. Allow Page fragments with multiple 'root' elements, like radio button group. See also Testing Radio button group with Arquillian Graphene
  2. Injecting utility classes which don't have a root but need the WebDriver, like utility class for handling alert's.
  3. 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.
  4. 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, ...
Multiple roots

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

Injecting utility classes

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.

Detecting widget

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 :

  1. No argument method which returns a boolean (return false means the Page fragment can't work with the supplied element in the root.
  2. 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.

Single set of Page Fragments

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.

Proof of concept

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.

Feedback

Of course, any feedback on the approach, issues or improvements are welcome of course.

About

Arquillian Graphene extension

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages