1

I wanna run selenium tests from TeamCity using Maven at Linux server without display.

While running Selenium tests I'm getting the following error in TeamCity:

Failed to execute goal org.codehaus.mojo:selenium-maven-plugin:2.3:xvfb (xvfb) on project my-project:
It appears that the configured display is already in use: :1

I installed x11-fonts*, xvfb, firefox, extracted DISPLAY=localhost:1, started xvfb

In pom.xml I added the following plugin:

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>selenium-maven-plugin</artifactId>
                    <version>2.3</version>
                    <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>

Do you have any ideas how to fix this problem?

UPD: xvfb is running using commmand

Xvfb :1 -screen 0 1920x1200x24 > /dev/null 2>&1 &

UPD: Before I've tried not to run xvfb before running tests, but was getting:

Execution xvfb of goal org.codehaus.mojo:selenium-maven-plugin:2.3:xvfb failed: Execute failed: java.io.IOException: Cannot run program "xauth": java.io.IOException: error=2, No such file or directory
Dmitriy Sukharev
  • 1,084
  • 2
  • 11
  • 20

2 Answers2

1

The error message tells you there is already an X server running on display number 1. From what you say:

I installed x11-fonts*, xvfb, firefox, extracted DISPLAY=localhost:1, started xvfb ... I added the following plugin

it seems that you started a server, and then the plugin tried to start it once more (as it should). I'd try not starting xvfb beforehand (ensure it doesn't run).

Or get rid of the display number in the plugin configuration altogether, it will try to find a free display number. It won't use your xvfb instance, though.

jpalecek
  • 47,058
  • 7
  • 102
  • 144
  • When I hadn't started xvfb I got this error: Execution xvfb of goal org.codehaus.mojo:selenium-maven-plugin:2.3:xvfb failed: Execute failed: java.io.IOException: Cannot run program "xauth": java.io.IOException: error=2, No such file or directory – Dmitriy Sukharev Jun 14 '12 at 11:03
  • @DmitriySukharev: That means it couldn't find `xauth`. It should be in `/usr/bin/xauth` (check it!), there may be some problem with PATH if it can't be found. Anyway, you can just specify the path to the executable in http://mojo.codehaus.org/selenium-maven-plugin/xvfb-mojo.html#xauthExecutable. Or disable xauth altogether if that helps. – jpalecek Jun 14 '12 at 11:21
  • Disabling xauth didn't help. Ok. I've founded that this plugin is for previous version of Selenium and that new Selenium works fine even without of xvfb. But I can't make it work, I'm getting " org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: Error: cannot open display: localhost:1". Maybe you know how to solve it? – Dmitriy Sukharev Jun 14 '12 at 12:24
  • @DmitriySukharev any success with your issue from the comment above? As I've encounteres similar one and struggling with making it work :) – Tomasz Dziurko May 02 '13 at 07:28
  • Tomasz Dziurko, I made it work a year ago (see my answer in this topic on Jun 15 '12 at 5:09). – Dmitriy Sukharev May 02 '13 at 09:21
1

I removed plugin declaration from pom.xml (as far as got to know that it's for previous version of Selenium), installed xauth (not sure that was necessary) and everything began to work.

Dmitriy Sukharev
  • 1,084
  • 2
  • 11
  • 20