2 Replies Latest reply on Mar 28, 2013 4:57 AM by jensmander

    Can't get test running with Arquillian + Drone + Webdriver

    jensmander

      Hi,

       

      my problem bases on the arquillian-drone-tutorial project. I am trying to get it running by using Webdriver interface instead of DefaultSelenium. Unfortunatelly it fails with

       

      java.lang.NoClassDefFoundError: com/opera/core/systems/OperaDriver

          at java.lang.Class.getDeclaredMethods0(Native Method)

          at java.lang.Class.privateGetDeclaredMethods(Class.java:2436)

          at java.lang.Class.getDeclaredMethods(Class.java:1793)

          at org.jboss.arquillian.core.impl.Reflections.getObserverMethods(Reflections.java:52)

          at org.jboss.arquillian.core.impl.ExtensionImpl.of(ExtensionImpl.java:51)

          at org.jboss.arquillian.core.impl.ManagerImpl.inject(ManagerImpl.java:198)

          at org.jboss.arquillian.core.impl.InjectorImpl.inject(InjectorImpl.java:58)

          at org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader.createServiceInstance(ServiceRegistryLoader.java:108)

          at org.jboss.arquillian.core.impl.loadable.ServiceRegistryLoader.all(ServiceRegistryLoader.java:55)

          at org.jboss.arquillian.drone.impl.DroneRegistrar.registerConfigurators(DroneRegistrar.java:84)

          at org.jboss.arquillian.drone.impl.DroneRegistrar.register(DroneRegistrar.java:77)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

          at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

          at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeSuite(EventTestRunnerAdaptor.java:68)

          at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:97)

          at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)

          at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)

          at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          at java.lang.reflect.Method.invoke(Method.java:597)

          at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)

          at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)

          at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)

          at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)

          at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)

       

      My pom.xml looks like that

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="
              http://maven.apache.org/POM/4.0.0
              http://maven.apache.org/xsd/maven-4.0.0.xsd">
      
          <!-- ... -->
          
          <properties>
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
              <version.selenium>2.31.0</version.selenium>
              <version.arquillian>1.0.3.Final</version.arquillian>
              <version.drone>1.1.1.Final</version.drone>
          </properties>
      
          <dependencyManagement>
              <dependencies>
                  <dependency>
                      <groupId>org.jboss.arquillian</groupId>
                      <artifactId>arquillian-bom</artifactId>
                      <version>${version.arquillian}</version>
                      <scope>import</scope>
                      <type>pom</type>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.arquillian.extension</groupId>
                      <artifactId>arquillian-drone-bom</artifactId>
                      <version>${version.drone}</version>
                      <type>pom</type>
                      <scope>import</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.arquillian.selenium</groupId>
                      <artifactId>selenium-bom</artifactId>
                      <version>${version.selenium}</version>
                      <type>pom</type>
                      <scope>import</scope>
                  </dependency>
              </dependencies>
          </dependencyManagement>
      
          <build>
              <plugins>
                  <plugin>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <version>2.3.2</version>
                      <configuration>
                          <source>1.6</source>
                          <target>1.6</target>
                      </configuration>
                  </plugin>
                  <plugin>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <version>2.12</version>
                  </plugin>
              </plugins>
          </build>
      
          <dependencies>
              <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>4.8.1</version>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.jboss.arquillian.junit</groupId>
                  <artifactId>arquillian-junit-container</artifactId>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.jboss.arquillian.extension</groupId>
                  <artifactId>arquillian-drone-impl</artifactId>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.jboss.arquillian.extension</groupId>
                  <artifactId>arquillian-drone-webdriver</artifactId>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.seleniumhq.selenium</groupId>
                  <artifactId>selenium-java</artifactId>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.seleniumhq.selenium</groupId>
                  <artifactId>selenium-server</artifactId>
                  <scope>test</scope>
                  <exclusions>
                      <exclusion>
                          <groupId>org.mortbay.jetty</groupId>
                          <artifactId>servlet-api-2.5</artifactId>
                      </exclusion>
                  </exclusions>
              </dependency>
              <dependency>
                  <groupId>org.seleniumhq.selenium</groupId>
                  <artifactId>selenium-firefox-driver</artifactId>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>org.slf4j</groupId>
                  <artifactId>slf4j-simple</artifactId>
                  <version>1.6.4</version>
                  <scope>test</scope>
              </dependency>
          </dependencies>
          <profiles>
              <profile>
                  <id>arquillian-jbossas-managed</id>
                  <activation>
                      <activeByDefault>true</activeByDefault>
                  </activation>
                  <dependencies>
                      <dependency>
                          <groupId>org.jboss.spec</groupId>
                          <artifactId>jboss-javaee-web-6.0</artifactId>
                          <version>2.0.0.Final</version>
                          <type>pom</type>
                          <scope>provided</scope>
                          <exclusions>
                              <exclusion>
                                  <groupId>org.apache.xalan</groupId>
                                  <artifactId>xalan</artifactId>
                              </exclusion>
                          </exclusions>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.as</groupId>
                          <artifactId>jboss-as-arquillian-container-managed</artifactId>
                          <version>7.1.1.Final</version>
                          <scope>test</scope>
                      </dependency>
                      <dependency>
                          <groupId>org.jboss.arquillian.protocol</groupId>
                          <artifactId>arquillian-protocol-servlet</artifactId>
                          <scope>test</scope>
                      </dependency>
                  </dependencies>
                  <build>
                      <plugins>
                          <plugin>
                              <artifactId>maven-dependency-plugin</artifactId>
                              <executions>
                                  <execution>
                                      <id>unpack</id>
                                      <phase>process-test-classes</phase>
                                      <goals>
                                          <goal>unpack</goal>
                                      </goals>
                                      <configuration>
                                          <artifactItems>
                                              <artifactItem>
                                                  <groupId>org.jboss.as</groupId>
                                                  <artifactId>jboss-as-dist</artifactId>
                                                  <version>7.1.1.Final</version>
                                                  <type>zip</type>
                                                  <overWrite>false</overWrite>
                                                  <outputDirectory>target</outputDirectory>
                                              </artifactItem>
                                          </artifactItems>
                                      </configuration>
                                  </execution>
                              </executions>
                          </plugin>
                      </plugins>
                  </build>
              </profile>
          </profiles>
      </project>
      

       

      I also added this extension config to arquillian.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <arquillian xmlns="http://jboss.org/schema/arquillian"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="
              http://jboss.org/schema/arquillian
              http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
      
          <container qualifier="jbossas-managed" default="true">
              <configuration>
                  <!-- If you want to use an existing JBoss AS installation, change the value of this property to that path -->
                  <!-- If you've already set the JBOSS_HOME environment variable, you can remove this configuration block -->
                  <property name="jbossHome">target/jboss-as-7.1.1.Final</property>
                  <property name="javaVmArguments">-Xmx512m -XX:MaxPermSize=128m -Xverify:none -XX:+UseFastAccessorMethods
                  </property>
                  <property name="outputToConsole">true</property>
              </configuration>
          </container>
      
      
          <extension qualifier="webdriver">
              <property name="browserCapabilities">firefox</property>
              <property name="loggingPrefs">driver=INFO,profiler=WARNING</property>
          </extension>
      
      </arquillian>
      

       

      And finally the test case

       

      @RunWith(Arquillian.class)
      public class LoginScreenSeleniumTest {
          private static final String WEBAPP_SRC = "src/main/webapp";
      
          @Deployment(testable = false)
          public static WebArchive createDeployment() {
              return ShrinkWrap.create(WebArchive.class, "login.war")
                      .addClasses(LoginController.class, User.class, Credentials.class)
                              // .addAsWebResource(new File(WEBAPP_SRC), "login.xhtml")
                              // .addAsWebResource(new File(WEBAPP_SRC), "home.xhtml")
                      .merge(ShrinkWrap.create(GenericArchive.class).as(ExplodedImporter.class)
                              .importDirectory(WEBAPP_SRC).as(GenericArchive.class),
                              "/", Filters.include(".*\\.xhtml$"))
                      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
                      .addAsWebInfResource(
                              new StringAsset("<faces-config version=\"2.0\"/>"),
                              "faces-config.xml");
          }
      
          @Drone
          FirefoxDriver browser;
          //        WebDriver browser;
      
          @ArquillianResource
          URL deploymentUrl;
      
          @Test
          public void should_login_with_valid_credentials() {
              browser.get(deploymentUrl.toString().replaceFirst("/$", "") + "/login.jsf");
              browser.findElement(By.id("loginForm:username")).sendKeys("user1");
              browser.findElement(By.id("loginForm:password")).sendKeys("demo");
              browser.findElement(By.id("loginForm:login")).click();
              Assert.assertTrue("User should be logged in!",
                      !browser.findElements(By.xpath("//li[contains(text(),'Welcome')]")).isEmpty());
          }
      

       

       

      I don't even want to use Opera browser. My whole setup was made for firefox so I don't have any clue why this is happening and why I should add Opera to my classpath.

      May anybody give my some piece of advise how to fix it? Thanks a lot

       

      Sascha

        • 1. Re: Can't get test running with Arquillian + Drone + Webdriver
          kpiwko

          Hi Jens,

           

          you're missing OperaDriver on the classpath. For you convenience, there is a single dependency you can import when working with webdriver.

           

           

          <dependency>

           

              <groupId>org.jboss.arquillian.extension</groupId>

              <artifactId>arquillian-drone-webdriver-depchain</artifactId>

              <version>${version.org.jboss.arquillian.drone}</version>

              <type>pom</type>

              <scope>test</scope>

          </dependency>

           

          All this can go away:

           

          <dependency>
                      <groupId>org.jboss.arquillian.junit</groupId>
                      <artifactId>arquillian-junit-container</artifactId>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.arquillian.extension</groupId>
                      <artifactId>arquillian-drone-impl</artifactId>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.jboss.arquillian.extension</groupId>
                      <artifactId>arquillian-drone-webdriver</artifactId>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.seleniumhq.selenium</groupId>
                      <artifactId>selenium-java</artifactId>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.seleniumhq.selenium</groupId>
                      <artifactId>selenium-server</artifactId>
                      <scope>test</scope>
                      <exclusions>
                          <exclusion>
                              <groupId>org.mortbay.jetty</groupId>
                              <artifactId>servlet-api-2.5</artifactId>
                          </exclusion>
                      </exclusions>
                  </dependency>
                  <dependency>
                      <groupId>org.seleniumhq.selenium</groupId>
                      <artifactId>selenium-firefox-driver</artifactId>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.slf4j</groupId>
                      <artifactId>slf4j-simple</artifactId>
                      <version>1.6.4</version>
                      <scope>test</scope>
                  </dependency>

           

          See https://docs.jboss.org/author/display/ARQ/Drone for more details.

           

          Karel

          • 2. Re: Can't get test running with Arquillian + Drone + Webdriver
            jensmander

            Hi Karel,

             

            thanks a lot. The dependency chain fixed my problem. Unfortunatelly the tests didn't run immediatelly afterwards but the failure changed. Now Firefox pops up but that's it. Nothing happens. After a while the test breaks with this stacktrace

             

            org.arquillian.example.ui.LoginScreenSeleniumTest: Unable to instantiate Drone via org.openqa.selenium.firefox.FirefoxDriver(Capabilities)
                    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
                      at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
                      at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
                      at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:188)
                      at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
                      at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:100)
                      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
                      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
                      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
                      at org.jboss.arquillian.drone.webdriver.factory.SecurityActions.newInstance(SecurityActions.java:142)
                      at org.jboss.arquillian.drone.webdriver.factory.FirefoxDriverFactory.createInstance(FirefoxDriverFactory.java:83)
                      at org.jboss.arquillian.drone.webdriver.factory.FirefoxDriverFactory.createInstance(FirefoxDriverFactory.java:38)
                      at org.jboss.arquillian.drone.impl.DroneCreator.createWebTestBrowser(DroneCreator.java:71)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
                      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
                      at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
                      at org.jboss.arquillian.drone.impl.DroneConfigurator.configureDrone(DroneConfigurator.java:116)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
                      at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
                      at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
                      at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
                      at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)
                      at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)
                      at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)
                      at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:182)
                      at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)
                      at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)
                      at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)
                      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                      at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)
                      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
                      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
                      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                      at java.lang.reflect.Method.invoke(Method.java:597)
                      at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
                      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
                      at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
                      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
                      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
            
            

             

            This exception was already described in https://issues.jboss.org/browse/ARQ-1314

            But it only describes the creation of the stacktrace not the cause itself. I checked out the latest 1.2.0.Final-SNAPSHOT version and build it locally. I'm not quite sure if there was some kind of bugfix in Drone. Probably there was a fix in selenium while now version 2.31.0 is used.

            I didn't dive deeper so 1.2.0.Final-SNAPSHOT works fine for now

             

            So thanks again.

             

            Sascha