Since we wrote this post we didn't laze around. Check our latest announcement.
The Arquillian team is proud to announce the 2.0.0.Alpha5 release of the Graphene component!
The last step before Beta release brings you a lot of new features.
Highlighted Changes
- Deprecations in this release
With the support of the community, we have recognized that some parts of the API needs to be enhanced to achieve better clarity, readability and consistency. The old parts are deprecated in this release, and will be removed in the upcoming Beta1 release. (list of deprecations here)
- Guard Improvements and Fixes
RequestGuard interface is now exposed as an API and brings new methods for filtering the requests that should be intercepted. This is especially useful in cases where your page does asynchronously communicate with a server (using Comet/Push method) which can make your tests undeterministic – the asynchronously invoked request can interfere with a request invoked synchronously (e.g. by clicking on a button) and Graphene can’t guess which request should be observed. With the RequestGuard
API you can ignore the request which you’re not interested in guarding. (JavaDoc)
- Support for parallel browser sessions
The Graphene context is no longer thread-local which enables parallel browser sessions. In other words; you can control two different browsers in one test. (an example here)
- Page Objects can encapsulate their location
You can easily denote the Page Objects location via the @Location
annotation. When used with @InitialPage
annotation as a test parameter, Graphene will load that location as a first action for the test, and will also give you the initialized page object. (an example here)
- Injecting elements from HTML frames/iframes
To facilitate the tedious process of switching to and from a particular frame/iframe; you can now just use the @InFrame
annotation to specify in which frame the element should be located. The details are handled by Graphene. (an example here)
- Page Fragments can implement the
WebElement
interface
If you want to give your Page Fragments all the capabilities of the WebElement
interface, without implementing them youself; you can simply add implements WebElement
and make your fragment abstract
. Graphene will provide you with a proxy that delegates all the WebElement
method invocations to your page fragment’s @Root
element.
- Drone enrichers for Page Fragments and Page Objects
It is now possible to inject objects into your Page Fragments and Page Objects via the standard Arquillian enrcihment annotations: e.g. @Drone
to get the browser instance, @ArquillianResource
to get resources like URL
, JavascriptExecutor
, LocalStorage
or others.
- Introduction of the
GrapheneElement
GrapheneElement
is our way of providing you with the missing methods of the WebElement
interface. GrapheneElement
can be used anywhere the WebElement
is used. Currently the only addition is the isPresent
method, but we plan to add far more in the upcoming releases.
- Introduction of the
@FindByJQuery
annotation
This is the replacement for the deprecated @FindBy
annotation. Read more about it in the deprecations section.
- Drone upgraded to 1.2.0.Beta1
For more info, please see the Drone release annoucement here.
Removed
-
Graphene.guardXhr()
Graphene.guardXhr()
was replaced by Graphene.guardAjax()
.
Deprecations (will be removed in Beta1)
- Our implementation of the
@FindBy
annotation
To achieve better extendability and to avoid errors caused by mistyped package name, we decided to deprecate our implementation of the @FindBy
annotation (read more). Its purpose was solely to add support for JQuery locating strategy. This is now replaced by the @FindByJQuery
annotation. The main advantage of the new approach is its extensibility. Support for our own location strategies are guaranteed via LocationStrategy interface.
- Package name changes for
@Page
and @Root
annotations
org.jboss.arquillian.graphene.spi.annotations.Root
replaced by org.jboss.arquillian.graphene.fragment.Root
org.jboss.arquillian.graphene.spi.annotations.Page
replaced by org.jboss.arquillian.graphene.fragment.Page
- Selenium 1 support
Selenium 1 support will be removed in the upcoming Beta1 release, but you can still use Graphene 1, which is built on top of Selenium 1. (Graphene 1 docs)
Parallel browser sessions
Your test can now use more than one browser session. It might be handy for testing e.g. server push functionality. Consider the following scenario:
@Browser1
@Drone
private WebDriver browser1;
@Browser2
@Drone
private WebDriver browser2;
public void testServerPushFromFirefoxToChromeAfterRegistration() {
browser1.get(“http://localhost:8080/myApp”);
browser2.get(“http://localhost:8080/myApp”);
formFragment.registerUser(new User(“John”), browser1);
registeredUsers.assertContains(“John”, browser2);
}
The @Browser1
and @Browser2
annotations are qualifiers, similar concept as in CDI. The settings for these browsers can be set e.g. in the arquillian.xml
:
<extension qualifier="webdriver-browser1">
<property name="browserCapabilities">firefox</property>
</extension>
<extension qualifier="webdriver-browser2">
<property name="browserCapabilities">chrome</property>
</extension>
Page Objects location encapsulated
First thing you have to keep in mind before interacting with the page is that its loading in the browser. Once the URL of the particular page changes, you will have to change it on several places in your tests.
Graphene, therefore, encapsulates the page’s location, and provide you with a way to load the page automatically on a correct context root, before the test execution.
Consider following snippet:
@Location("register-page.html")
public class RegisterPage {
//implementation of the page object goes here
}
@Test
public void testRegisterPage(@InitialPage RegisterPage page) {
//Graphene automatically load MyPageObject location in the browser
page.getInput().sendKeys(“Blah foo”);
page.submit();
assertFalse(page.isSubmitted());
}
You can also leverage Graphene.goTo(RegisterPage.class)
method, which will use the @Location
annotation value to load the correct page in the browser.
Elements from frames/iframes
If you find working with frames/iframes tedious using the WebDriver
API, we have some good news for you. Graphene is now able to specify in which frame/iframe an element reside. Consider the following snippet:
@Page
@InFrame(index = 0)
private PageObject page;
@FindBy(id = "foo-bar")
@InFrame(nameOrId = "second")
private PageFragment myFragment;
You can specify the frame either by its index or its nameOrId
strategy. Graphene will automatically switche to the coresponding frame when interacting with the page object and switches back after the interaction.
Roadmap
We have introduced all the features for the upcoming Graphene 2.0 release.
The Beta1 release will be pushed in a few days which will bring you some more goodies:
- Arquillian guide
- finished reference documentation
- online JavaDoc documentation for Graphene API
- removal of deprecated APIs
- stabilization
- usual portion of bug fixes
Be sure to remove deprecated APIs in order to stay compatible with upcoming Graphene 2.0 releases.
What is Arquillian?
Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.
Release details
Component |
Graphene
|
Version |
2.0.0.Alpha5
view tag
|
Release date |
2013-09-03 |
Released by |
Lukas Fryc |
Compiled against |
|
Published artifacts
org.jboss.arquillian.graphene
-
org.jboss.arquillian.graphene
»
graphene-parent
pom
-
org.jboss.arquillian.graphene
»
graphene-selenium-parent
pom
-
org.jboss.arquillian.graphene
»
graphene-selenium-api
jar
javadoc
pom
-
org.jboss.arquillian.graphene
»
graphene-selenium-impl
jar
javadoc
pom
-
org.jboss.arquillian.graphene
»
graphene-selenium-drone
jar
javadoc
pom
-
org.jboss.arquillian.graphene
»
graphene-selenium
pom
-
org.jboss.arquillian.graphene
»
graphene-webdriver-parent
pom
-
org.jboss.arquillian.graphene
»
graphene-webdriver-api
jar
javadoc
pom
-
org.jboss.arquillian.graphene
»
graphene-webdriver-spi
jar
javadoc
pom
-
org.jboss.arquillian.graphene
»
graphene-webdriver-impl
jar
javadoc
pom
-
org.jboss.arquillian.graphene
»
graphene-webdriver
pom
-
org.jboss.arquillian.graphene
»
arquillian-graphene
pom
-
org.jboss.arquillian.graphene
»
graphene-component-api
jar
javadoc
pom
Release notes and resolved issues
32
Q3/13: SauceLabs; Context Propagation (Multiple Browsers Support); Continuous Integration
- Component Upgrade
-
- ARQGRA-323 - Update Arquillian Drone to 1.2, Arquillian Core to 1.1 and Selenium to 2.35
- Enhancement
-
- ARQGRA-236 - Made @FindBy annotation lookup mechanism extensible
- ARQGRA-275 - Implement Guard observers which will filter out which request we want to intercept
- ARQGRA-336 - Introduce FindByJQuery annotation
- Feature Request
-
- ARQGRA-72 - Support parallel browser sessions API for Selenium 2
- ARQGRA-170 - Merge all static contexts to one (GrapheneContext)
- ARQGRA-197 - Support for Page Objects encapsulating location
- ARQGRA-224 - Page Fragments implementing WebElement delegate interface invocations to Root
- ARQGRA-243 - Infer Graphene API from Impl module
- ARQGRA-264 - Create possibility to "inject" elements from frames
- ARQGRA-279 - Support for method Graphene.element(WebElement, By) and its condition isPresent
- ARQGRA-291 - Provide wait until element is enabled
- ARQGRA-296 - Provide a way for checking whether an element is present
- ARQGRA-306 - Guards: Provide settings for customizing maximum timeout for callbacks scheduled in XHR onreadystatechange
- Epic
-
- ARQGRA-271 - The context should not be shared in static context, but propagated from the test as central point to the users (e.g. page fragments)
- ARQGRA-276 - GhostDriver / PhantomJS support
- ARQGRA-281 - Guard Improvements
- ARQGRA-285 - Page Abstract. Improvements
- ARQGRA-294 - Introduce an own implementation of WebElement
- Bug
-
- ARQGRA-274 - The request guard does timeout for delayed requests
- ARQGRA-300 - Guard Ajax ends with timeout exception
- ARQGRA-304 - The interceptor for handling StaleElementReferenceException is not present
- ARQGRA-324 - ByChained doesn't work when jquerySelector is used
- ARQGRA-327 - Graphene depends on deprecated interactions interfaces (Keyboard, Mouse, TouchScreen) removed in selenium 2.35.0
- Task
-
- ARQGRA-299 - Setup Graphene tests on SauceLabs
- ARQGRA-339 - Deprecate Graphene's FindBy and How classes
- Sub-task
-
Thanks to the following list of contributors:
Lukas Fryc, Jan Papoušek, Juraj Huska, Marek Schmidt, Karel Piwko