Usage

NOTE: The examples below, unless otherwise specified, all assume that the Maven build is invoked with a life-cycle phase:

mvn install

Due to the use of executions configurations, invoking the named goals from the command-line will fail to function correctly.

Start Selenium Server (Integrated)

For integration tests that need a Selenium server, use the pre-integration-test phase to start it up in the background to allow the integration-test phase to be executed with the server running.

This will by default create files under ${pom.basedir}/target/selenium , including:

  • server.log (if enabled)
  • user-extensions.js (if enabled)
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>selenium-maven-plugin</artifactId>
        <executions>
            <execution>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>start-server</goal>
                </goals>
                <configuration>
                    <background>true</background>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

Start Selenium Server (Standalone)

To start Selenium on the command line, which is very useful while developing tests, simply execute the start-server goal.

This will start the server and block until the server has been stopped, either from the process being killed, or more normally, until CTRL-C is used to exit Maven.

This is the preferred mechanism to start the server standalone, as it will setup user-extensions.js .

mvn selenium:start-server

Stopping Selenium Server

Its not really nessicary, as the process will exit when the Maven JVM exists, but if needed the server can be started and stopped explicitly via:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>selenium-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>start</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start-server</goal>
            </goals>
            <configuration>
                <background>true</background>
            </configuration>
        </execution>
        
        <execution>
            <id>stop</id>
            <phase>post-integration-test</phase>
            <goals>
                <goal>stop-server</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Logging Output

To capture the logs from Selenium to a file, enable logOutput . This will create a server.log that captures all of the output.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>selenium-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>start-server</goal>
            </goals>
            <configuration>
                <logOutput>true</logOutput>
            </configuration>
        </execution>
    </executions>
</plugin>

Debugging

Sometimes it is useful to startup Selenium with its debug output enabled.

mvn selenium:start-server -Ddebug=true