Fix “Could not start Selenium session… Error starting browser ” (maven + TestNG + headless unix)

By neokrates, written on April 27, 2010

howto

  • Join date: 11-30-99
  • Posts: 224
View Counter:
  • 157 views
Rate it
Ad
Poll
  • Which Selenium configurations do you use to test your web front end?

    View Results

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext

That is a common configuration to run many browser tests under selenium. One specific case is headless unix, i.e. hardware without monitor. The problem is to let browser run without X-Server. The described solution allows gui-based browsers to run under selenium. It fixes “Error starting browser” in many, but not all cases.

Important: that fix only applies to headless systems. If on your target system, firefox already running under X-Server, this fix won’t help.

For headless systems it is important, that all gui-based software actually finds an X-Server. If display is not available, xvfb can help (http://de.wikipedia.org/wiki/Xvfb).
Don’t forget to properly install and configure Xvfb on the target system. Use apt-get, aptitude, etc… if it is not yet installed.

Software:

✔ Maven

✔ TestNG (or any other framework)

✔ Headless Unix

✔ Selenium

✔ Xvfb

The precondition is, that your maven + TestNG + Selenium project is already set up. Then, you have fully configured pom.xml.

Your DISPLAY environment variable is set to :1.0. If no, change <display>:1</display> in the code below accordingly. Add that execution to your pom.xml:


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

Here is more about selenium-maven-plugin and Xvfb : http://mojo.codehaus.org/selenium-maven-plugin/examples/headless-with-xvfb.html.

Have fun! ;-)

Be Sociable, Share!
 
Does that help to solve your problem?
VN:F [1.8.5_1061]
Rating: -1 (from 3 votes)
1 votes 'YES'  2 votes 'NO'

LEARN MORE (amazon bookstore)

TAGS

SOCIAL
Be Sociable, Share!

INCOMING SEARCH TERMS


Leave a Reply