Graphene 2 is building on top of the Selenium WebDriver API and provide extensions for writing reusable, robust and AJAX-enabled tests with improved readability.

Graphene 2 uses the ideas from Graphene 1 (based on Selenium 1 API) and applies it to the world of Selenium WebDriver.

You can read more about the difference between Graphene 1 and Graphene 2 in the Reference Documentation

Features

Page Abstractions

Page abstractions allow you to abstract page functionality using the well-known Selenium design pattern Page Objects. In Graphene you can inject page objects directly into the test case using the @Page annotation.

But we take the Page Objects pattern one step further with the concept of Page Fragments . Page Fragments are reusable parts within a page encapsulated into an object similar to Page Objects. A good example of Page Fragments are JavaScript widgets or forms.

The concept of Page Fragments comes from an idea that those components share a same underlying DOM structure, the only difference between all occurences of a component is a location in a DOM tree where a component is rendered – this is denoted by the @Root annotation. You can define this root location for each concrete occurence using a @FindBy(locator) annotation.

Fluent-API for Waiting Conditions

Graphene provides a set of widely used conditions to avoid writing them repeatedly.

Request Guards

Request guards block the Selenium test execution until a network communication caused by a given action ends. Guards support blocking on HTTP and XHR (AJAX) but can also be used to verify that no such requests were done.

Under the Hood

There are some low level features exposed as API that are used by Graphene internally. While not used regularly within a normal test, can be handy to write more robust tests:

JavaScript Interface

This allows you to write a Java interface which automatically translates Java API invocations to JavaScript calls:

@JavaScript
public interface Document {
    String getTitle();
}
Page Extensions

Page Extensions allow you to inject arbitrary JavaScript code in the page under the test. The javascript code might help you to test complex situations as well as bring completely new features for improving testing. Graphene internally uses Page Extensions for Request Guards.

Graphene Context

Graphene allows you to obtain current thread-local context of a browser session and inject it exactly where you need. No more need for driver reference propagation.

Documentation

Last but definitely not the least addition is the great documentation for all of the features above including answers for general questions like how Selenium 1, Graphene 1, Selenium WebDriver and Graphene 2 relates to each other, what’s the relation between Graphene’s, Drone and Arquillian.

Getting Started

It’s the same as with any other Arquillian extension: open the IDE, setup the Maven dependency and you are ready to start testing!

What’s next?

In the upcoming releases, we would like to focus on more new features as well as migrate some features from Graphene 1 to Graphene 2:

  • Forge plugin for quick start
  • command interceptors
  • parallel browser session control
  • jQuery/Sizzle locators
  • AJAX/HTTP Communication Halter
  • page abstraction improvements
  • closer integration with the Arquillian event system
  • helpers for writing browser specific code

Call to Action

Let us know what you think and help us shape Graphene to be what you want it to be.


blog comments powered by Disqus