Blog

Wednesday, 20 February 2013

Graphene hangs when page fragment not found

For the purpose of small workshop held at PWSZ in Tarnow. We've written quick test based on Graphene (2.0.0.Alpha3). Bad luck happened that after several hours the test stopped to work. No, it didn't fail, it hang!

Our test was clicking over http://showcase.richfaces.org and we found out that RF team has updated the site meanwhile, causing the JSF-based identifiers to change.
Yes, I know that it's not perfect to use such selector, but it was just for demonstration purposes and it's not an excuse for test to hang. It should fail instead.
Well, quick chat with +Pavol Pitoňák and we discovered that various dependencies of graphene-webdriver have transitive dependencies to different selenium version.
Our pom.xml looked like this:
    <dependencies>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <version>1.0.3.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-web-6.0</artifactId>
            <version>3.0.1.Final</version>
            <scope>provided</scope>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.graphene</groupId>
            <artifactId>graphene-webdriver</artifactId>
            <version>2.0.0.Alpha3</version>
            <type>pom</type>
            <scope>test</scope>
        </dependency>
    </dependencies>
This resulted in following dependency tree:
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ arquillian ---
[INFO] pl.itcrowd.tutorials.arquillian:arquillian:jar:1.0-SNAPSHOT
[INFO] +- org.jboss.arquillian.junit:arquillian-junit-container:jar:1.0.3.Final:test
[INFO] |  +- org.jboss.arquillian.junit:arquillian-junit-core:jar:1.0.3.Final:test
[INFO] |  +- org.jboss.arquillian.test:arquillian-test-api:jar:1.0.3.Final:test
[INFO] |  |  \- org.jboss.arquillian.core:arquillian-core-api:jar:1.0.3.Final:test
[INFO] |  +- org.jboss.arquillian.test:arquillian-test-spi:jar:1.0.3.Final:test
[INFO] |  |  \- org.jboss.arquillian.core:arquillian-core-spi:jar:1.0.3.Final:test
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-test-api:jar:1.0.3.Final:test
[INFO] |  |  \- org.jboss.shrinkwrap:shrinkwrap-api:jar:1.0.1:test
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-test-spi:jar:1.0.3.Final:test
[INFO] |  |  \- org.jboss.arquillian.container:arquillian-container-spi:jar:1.0.3.Final:test
[INFO] |  |     \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-base:jar:2.0.0-alpha-3:test
[INFO] |  +- org.jboss.arquillian.core:arquillian-core-impl-base:jar:1.0.3.Final:test
[INFO] |  +- org.jboss.arquillian.test:arquillian-test-impl-base:jar:1.0.3.Final:test
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-impl-base:jar:1.0.3.Final:test
[INFO] |  |  +- org.jboss.arquillian.config:arquillian-config-api:jar:1.0.3.Final:test
[INFO] |  |  +- org.jboss.arquillian.config:arquillian-config-impl-base:jar:1.0.3.Final:test
[INFO] |  |  \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-spi:jar:2.0.0-alpha-3:test
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-test-impl-base:jar:1.0.3.Final:test
[INFO] |  \- org.jboss.shrinkwrap:shrinkwrap-impl-base:jar:1.0.1:test
[INFO] |     \- org.jboss.shrinkwrap:shrinkwrap-spi:jar:1.0.1:test
[INFO] +- junit:junit:jar:4.8.2:test
[INFO] +- org.jboss.spec:jboss-javaee-web-6.0:pom:3.0.1.Final:provided
[INFO] |  +- javax.enterprise:cdi-api:jar:1.0-SP4:provided
[INFO] |  +- javax.inject:javax.inject:jar:1:provided
[INFO] |  +- javax.validation:validation-api:jar:1.0.0.GA:provided
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:provided
[INFO] |  +- org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.1.Final:provided
[INFO] |  +- org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:jar:1.0.2.Final:provided
[INFO] |  +- org.jboss.spec.javax.el:jboss-el-api_2.2_spec:jar:1.0.1.Final:provided
[INFO] |  +- org.jboss.spec.javax.faces:jboss-jsf-api_2.1_spec:jar:2.0.2.Final:provided
[INFO] |  +- org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.1_spec:jar:1.0.1.Final:provided
[INFO] |  +- org.jboss.spec.javax.resource:jboss-connector-api_1.6_spec:jar:1.0.1.Final:provided
[INFO] |  +- org.jboss.spec.javax.security.auth.message:jboss-jaspi-api_1.0_spec:jar:1.0.1.Final:provided
[INFO] |  +- org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:jar:1.0.1.Final:provided
[INFO] |  +- org.jboss.spec.javax.servlet.jsp:jboss-jsp-api_2.2_spec:jar:1.0.1.Final:provided
[INFO] |  +- org.jboss.spec.javax.servlet.jstl:jboss-jstl-api_1.2_spec:jar:1.0.3.Final:provided
[INFO] |  |  \- xalan:xalan:jar:2.7.1.jbossorg-2:provided
[INFO] |  |     \- xalan:serializer:jar:2.7.1.jbossorg-2:provided
[INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.1.Final:provided
[INFO] |  +- org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_1.1_spec:jar:1.0.1.Final:provided
[INFO] |  \- org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.2_spec:jar:1.0.4.Final:provided
[INFO] \- org.jboss.arquillian.graphene:graphene-webdriver:pom:2.0.0.Alpha3:test
[INFO]    +- org.jboss.arquillian.graphene:graphene-webdriver-impl:jar:2.0.0.Alpha3:test
[INFO]    |  +- org.jboss.arquillian.graphene:graphene-webdriver-spi:jar:2.0.0.Alpha3:test
[INFO]    |  \- org.jboss.arquillian.extension:arquillian-drone-configuration:jar:1.1.0.Final:test
[INFO]    +- org.jboss.arquillian.graphene:graphene-webdriver-drone:jar:2.0.0.Alpha3:test
[INFO]    |  +- org.jboss.arquillian.extension:arquillian-drone-api:jar:1.1.0.Final:test
[INFO]    |  +- org.jboss.arquillian.extension:arquillian-drone-spi:jar:1.1.0.Final:test
[INFO]    |  +- org.jboss.arquillian.extension:arquillian-drone-webdriver:jar:1.1.0.Final:test
[INFO]    |  +- org.jboss.arquillian.core:arquillian-core-impl-base:jar:tests:1.0.3.Final:test
[INFO]    |  \- org.jboss.arquillian.graphene:graphene-webdriver-impl:jar:tests:2.0.0.Alpha3:test
[INFO]    +- org.jboss.arquillian.extension:arquillian-drone-webdriver-depchain:pom:1.1.0.Final:test
[INFO]    |  +- org.jboss.arquillian.extension:arquillian-drone-impl:jar:1.1.0.Final:test
[INFO]    |  +- org.seleniumhq.selenium:selenium-api:jar:2.25.0:test
[INFO]    |  |  +- com.google.guava:guava:jar:12.0:test
[INFO]    |  |  |  \- com.google.code.findbugs:jsr305:jar:1.3.9:test
[INFO]    |  |  \- org.json:json:jar:20080701:test
[INFO]    |  +- org.seleniumhq.selenium:selenium-support:jar:2.25.0:test
[INFO]    |  +- org.seleniumhq.selenium:selenium-android-driver:jar:2.25.0:test
[INFO]    |  +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.25.0:test
[INFO]    |  +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.25.0:test
[INFO]    |  |  +- commons-io:commons-io:jar:2.0.1:test
[INFO]    |  |  \- org.apache.commons:commons-exec:jar:1.1:test
[INFO]    |  +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.25.0:test
[INFO]    |  |  +- net.sourceforge.htmlunit:htmlunit:jar:2.9:test
[INFO]    |  |  |  +- commons-collections:commons-collections:jar:3.2.1:test
[INFO]    |  |  |  +- commons-lang:commons-lang:jar:2.6:test
[INFO]    |  |  |  +- org.apache.httpcomponents:httpmime:jar:4.1.2:test
[INFO]    |  |  |  +- commons-codec:commons-codec:jar:1.4:test
[INFO]    |  |  |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.9:test
[INFO]    |  |  |  +- xerces:xercesImpl:jar:2.9.1:test
[INFO]    |  |  |  |  \- xml-apis:xml-apis:jar:1.3.04:test
[INFO]    |  |  |  +- net.sourceforge.nekohtml:nekohtml:jar:1.9.15:test
[INFO]    |  |  |  +- net.sourceforge.cssparser:cssparser:jar:0.9.5:test
[INFO]    |  |  |  |  \- org.w3c.css:sac:jar:1.3:test
[INFO]    |  |  |  \- commons-logging:commons-logging:jar:1.1.1:test
[INFO]    |  |  \- org.apache.httpcomponents:httpclient:jar:4.1.2:test
[INFO]    |  |     \- org.apache.httpcomponents:httpcore:jar:4.1.2:test
[INFO]    |  +- org.seleniumhq.selenium:selenium-ie-driver:jar:2.25.0:test
[INFO]    |  |  +- net.java.dev.jna:jna:jar:3.4.0:test
[INFO]    |  |  \- net.java.dev.jna:platform:jar:3.4.0:test
[INFO]    |  +- org.seleniumhq.selenium:selenium-iphone-driver:jar:2.25.0:test
[INFO]    |  +- org.seleniumhq.selenium:selenium-remote-driver:jar:2.25.0:test
[INFO]    |  |  \- cglib:cglib-nodep:jar:2.1_3:test
[INFO]    |  \- com.opera:operadriver:jar:1.1:test
[INFO]    |     +- com.opera:operalaunchers:jar:1.1:test
[INFO]    |     +- com.google.protobuf:protobuf-java:jar:2.4.1:test
[INFO]    |     +- commons-jxpath:commons-jxpath:jar:1.3:test
[INFO]    |     \- org.ini4j:ini4j:jar:0.5.2:test
[INFO]    \- org.seleniumhq.selenium:selenium-java:jar:2.28.0:test
[INFO]       +- org.seleniumhq.selenium:selenium-safari-driver:jar:2.28.0:test
[INFO]       \- org.webbitserver:webbit:jar:0.4.14:test
[INFO]          \- io.netty:netty:jar:3.5.2.Final:test
Notice that lines 92,93 show dependency on selenium 2.28.0 while others point to 2.25.0. This has caused the problems.

The solution turned to be very simple, we just needed to add org.jboss.arquillian.selenium:selenium-bom to dependencyManagement section above dependencies:
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian.selenium</groupId>
                <artifactId>selenium-bom</artifactId>
                <version>2.28.0</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>...</dependencies>
Please, note that this issue happens only when Arquillian is configured (defaults) to start selenium-server rather then reuse existing standalone one.

Pavol, thanks again for your assistance resolving this issue.