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

By neokrates, written on April 27, 2010

howto

Rate it
  • 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
Ad
Poll
  • Which test frameworks do you use?

    • Something different (91%, 10 Votes)
    • Selenium (9%, 1 Votes)
    • JUnit (or any other *unit*) (0%, 0 Votes)
    • Fit (0%, 0 Votes)
    • JBehave (0%, 0 Votes)
    • Mockito (or any other *mock*) (0%, 0 Votes)
    • Canoo WebTest (0%, 0 Votes)

    Total Voters: 11

    Vote

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext
Most popular search terms:

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:

[v] Maven
[v] TestNG (or any other framework)
[v] Headless Unix
[v] Selenium
[v] 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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
    <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! ;-)

 
Does that help to solve your problem?
VN:F [1.8.5_1061]
Rating: -2 (from 2 votes)
0 votes 'YES'  2 votes 'NO'

LEARN MORE (amazon bookstore)

TAGS

RELATED
Pages
Posts

SOCIAL
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BlinkList
  • Blogosphere News
  • E-mail this story to a friend!
  • Furl
  • LinkArena
  • Live
  • MisterWong
  • Print this article!
  • StumbleUpon
  • Technorati
  • Webnews.de
  • YahooMyWeb

INCOMING SEARCH TERMS


Leave a Reply