Maven and Selenium

Using Selenium for functional testing of webapps, with Maven

The following profile comes from the parent pom for the Apache Shale example apps.

See this page for more information: http://shale.apache.org/shale-apps/selenium.html

With Maven 2.0.4, putting both plugin executions in the process-resources phase did not work-- they were executed in the wrong order and so the build failed as Selenium had not yet been unzipped when antrun tried to copy the files. Moving the dependency-maven-plugin execution to generate-sources fixed the problem, but this should not have been necessary. See http://www.nabble.com/Plugin-execution-ordering-within-a-phase-t2543138s177.html

<profile>
   <id>selenium</id>
   <activation>
      <property>
         <name>selenium</name>
      </property>
   </activation>
   <build>
      <plugins>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>dependency-maven-plugin</artifactId>
            <executions>
               <execution>
                  <id>unzip-selenium</id>
                  <phase>generate-resources</phase>
                  <goals>
                     <goal>unpack</goal>
                  </goals>
                  <configuration>
                     <artifactItems>
                        <artifactItem>
                           <groupId>org.openqa.selenium.core</groupId>
                           <artifactId>selenium-core</artifactId>
                           <version>0.7.0</version>
                        </artifactItem>
                     </artifactItems>
                     <outputDirectory>${project.build.directory}/selenium</outputDirectory>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
               <execution>
                  <id>copy-selenium</id>
                  <phase>process-resources</phase>
                  <configuration>
                     <tasks>
                        <copy todir="${project.build.directory}/${artifactId}/selenium/core">
                           <fileset dir="${project.build.directory}/selenium/core"/>
                        </copy>
                        <copy todir="${project.build.directory}/${artifactId}/selenium/tests">
                           <fileset dir="${basedir}/src/test/selenium"/>
                        </copy>
                     </tasks>
                  </configuration>
                  <goals>
                     <goal>run</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
   <repositories>
      <repository>
         <id>OpenQA</id>
         <url>http://maven.openqa.org</url>
      </repository>
   </repositories>
</profile>

Using Selenium Maven Plugin and Cargo

Tutorial at Functional testing with Maven, Cargo and Selenium by Carlos Sanchez

Examples at Continuum web tests, Archiva web tests, and the Maven Web UI Tests.

Labels

 
(None)
  1. Dec 08, 2006

    David Santiago TuriƱo says:

    There is a simple plugin that lets you use SeleniumIDE HTML tests in your maven ...

    There is a simple plugin that lets you use Selenium-IDE HTML tests in your maven webapp project and integrates in maven's build life cycle, stopping it whenever a test fails.

    Upload to the maven central repository pending. http://mavenium.sourceforge.net/

  2. Feb 24, 2007

    Jason Dillon says:

    FYI, you can find a Maven2 plugin for starting up a selenium server here

    FYI, you can find a Maven2 plugin for starting up a selenium server here

    http://mojo.codehaus.org/selenium-maven-plugin/

  3. Mar 12, 2007

    carlos says:

    Matt Raible wrote a weblog entry Integrating Selenium with Maven 2

    Matt Raible wrote a weblog entry Integrating Selenium with Maven 2

  4. Jun 29, 2007

    Foochal says:

    A good page for beginners