0 Replies Latest reply on Apr 23, 2015 6:57 AM by pascal salg

    NoClassDefFoundError for Selenium when running in mixed mode

    pascal salg Newbie

      Hi,

       

      first of all I'd like to thank the authors for this great tutorial http://arquillian.org/guides/functional_testing_using_graphene/

       

      However I am getting a NoClassDefFoundError for org/openqa/selenium/WebDriver when my test runs in mixed mode.

      I don't see any difference from my code to the code presented in the tutorial.

       

      import org.jboss.arquillian.container.test.api.Deployment;

      import org.jboss.arquillian.container.test.api.RunAsClient;

      import org.jboss.arquillian.drone.api.annotation.Drone;

      import org.jboss.arquillian.junit.Arquillian;

      import org.jboss.arquillian.test.api.ArquillianResource;

      import org.jboss.shrinkwrap.api.Archive;

      import org.jboss.shrinkwrap.api.ShrinkWrap;

      import org.jboss.shrinkwrap.api.spec.WebArchive;

      import org.junit.Assert;

      import org.junit.Test;

      import org.junit.runner.RunWith;

      import org.openqa.selenium.By;

      import org.openqa.selenium.WebDriver;

      import org.openqa.selenium.WebElement;

      import org.openqa.selenium.support.FindBy;

       

       

       

      // http://arquillian.org/guides/functional_testing_using_graphene/

      @RunWith(Arquillian.class)

      public class DroneTest {

       

          @Deployment(testable = true)

          public static Archive<?> createTestArchive() {

              return ShrinkWrap.createFromZipFile(WebArchive.class, new File(

                      "path/to/my/warfile"));

          }

       

          @Drone

          private WebDriver driver;

       

          @FindBy

          private WebElement usrTxt;

       

          @FindBy

          private WebElement loginBtn;

       

          @ArquillianResource

          private URL deployment;

       

          @Inject

          private MyBean bean;

       

          @Test

          public void shouldInject() {

              Assert.assertNotNull(bean);

          }

       

          @Test

          @RunAsClient

          public void shouldLogin() {

              driver.get(deployment.toExternalForm() + "login.jsf");

              Assert.assertNotNull(usrTxt);

              Assert.assertNotNull(loginBtn);

              usrTxt.sendKeys("someuser");

              guardAjax(loginBtn).click();

              Assert.assertNotNull(driver.findElement(By.className("some-css-class")));

          }

       

      }

       

      Currently my best guess is that this has to do with the fundamental difference between in-container mode and client mode (being that in-container mode repackages the deployment and skips the webdriver dependencies as they have the "test" scope)

       

      Here is an excerpt from my pom.xml:

       

      <?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/maven-v4_0_0.xsd">

          <modelVersion>4.0.0</modelVersion>

          <parent>

              <artifactId>my</artifactId>

              <groupId>web-war</groupId>

              <version>0.0.1-SNAPSHOT</version>

          </parent>

       

          <artifactId>web-war</artifactId>

          <packaging>war</packaging>

       

          <repositories>

               ...

          </repositories>

       

          <properties>

              ...

              <browser>firefox</browser>

          </properties>

       

       

          <dependencyManagement>

              <dependencies>

                  <dependency>

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

                      <artifactId>arquillian-bom</artifactId>

                      <version>1.1.5.Final</version>

                      <type>pom</type>

                      <scope>import</scope>

                  </dependency>

                  <dependency>

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

                      <artifactId>arquillian-drone-bom</artifactId>

                      <version>1.3.1.Final</version>

                      <type>pom</type>

                      <scope>import</scope>

                  </dependency>

                  <dependency>

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

                      <artifactId>selenium-bom</artifactId>

                      <version>2.43.1</version>

                      <type>pom</type>

                      <scope>import</scope>

                  </dependency>

                

                  <dependency>

                      <groupId>org.jboss.bom</groupId>

                      <artifactId>jboss-javaee-6.0-with-tools</artifactId>

                      <version>${version.jboss.bom}</version>

                      <type>pom</type>

                      <scope>import</scope>

                  </dependency>

                

              </dependencies>

          </dependencyManagement>

       

          <dependencies>

       

              <dependency>

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

                  <artifactId>arquillian-junit-container</artifactId>

                  <scope>test</scope>

              </dependency>

               ... (note: junit is a transitive dependency already provided by another module of my project) ...

              <dependency>

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

                  <artifactId>graphene-webdriver</artifactId>

                  <version>2.0.3.Final</version>

                  <type>pom</type>

                  <scope>test</scope>

              </dependency>

              <dependency>

                  <groupId>org.jboss.as</groupId>

                  <artifactId>jboss-as-arquillian-container-remote</artifactId>

                  <version>7.1.1.Final</version>

                  <scope>test</scope>

              </dependency>

       

       

                ...

              <!-- Needed for running some other tests -->

              <dependency>

                  <groupId>org.testng</groupId>

                  <artifactId>testng</artifactId>

                  <version>6.8.21</version>

                  <scope>test</scope>

              </dependency>

               ...

          </dependencies>

       

          <build>

               ...

          </build>

       

          <profiles>

              <profile>

                  <id>firefox</id>

                  <properties>

                      <browser>firefox</browser>

                  </properties>

              </profile>

              <profile>

                  <id>chrome</id>

                  <properties>

                      <browser>chrome</browser>

                  </properties>

              </profile>

            

              <profile>

                  <id>arq-jbossas-remote</id>

                  <dependencies>

                      <dependency>

                          <groupId>org.jboss.as</groupId>

                          <artifactId>jboss-as-arquillian-container-remote</artifactId>

                          <scope>test</scope>

                      </dependency>

                  </dependencies>

              </profile>

          </profiles>

      </project>

       

       

      Maybe someone has an idea? Any help or pointers would be greatly appreciated

       

      Best regards

      paul