【问题标题】:xvfb with Selenium. Display is already in use errorxvfb 与硒。显示器已在使用错误
【发布时间】:2012-06-17 09:31:11
【问题描述】:

我想在没有显示的情况下在 Linux 服务器上使用 Maven 从 TeamCity 运行 selenium 测试。

在运行 Selenium 测试时,我在 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

我安装了x11-fonts*、xvfb、firefox,解压DISPLAY=localhost:1,启动xvfb

在 pom.xml 中我添加了以下插件:

                <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>

你有什么想法可以解决这个问题吗?

UPD: xvfb 正在使用命令运行

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

UPD:在我尝试在运行测试之前不运行 xvfb 之前,但得到:

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

【问题讨论】:

    标签: java linux selenium headless xvfb


    【解决方案1】:

    错误信息告诉你已经有一个 X 服务器在 1 号显示器上运行。从你说的来看:

    我安装了 x11-fonts*、xvfb、firefox,提取了 DISPLAY=localhost:1,启动了 xvfb ...我添加了以下插件

    您似乎启动了一个服务器,然后插件尝试再次启动它(应该如此)。我会尝试 not 事先启动 xvfb(确保它不会运行)。

    或者完全去掉插件配置中的显示编号,它会尝试寻找一个空闲的显示编号。不过,它不会使用你的 xvfb 实例。

    【讨论】:

    • 当我没有启动 xvfb 时,我得到了这个错误: Execution xvfb of goal org.codehaus.mojo:selenium-maven-plugin:2.3:xvfb failed: Execute failed: java.io.IOException:无法运行程序“xauth”:java.io.IOException: error=2, No such file or directory
    • @DmitriySukharev:这意味着它找不到xauth。它应该在/usr/bin/xauth 中(检查一下!),如果找不到,PATH 可能有问题。无论如何,您可以在mojo.codehaus.org/selenium-maven-plugin/… 中指定可执行文件的路径。如果有帮助,或者完全禁用 xauth。
    • 禁用 xauth 没有帮助。好的。我发现这个插件适用于以前版本的 Selenium,即使没有 xvfb,新的 Selenium 也能正常工作。但我不能让它工作,我得到“ org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox 控制台输出:错误:无法打开显示:本地主机:1"。也许你知道如何解决它?
    • @DmitriySukharev 从上面的评论中您的问题是否成功?因为我遇到过类似的并且努力使它工作:)
    • Tomasz Dziurko,我在一年前就成功了(请参阅我在 2012 年 6 月 15 日 5:09 在本主题中的回答)。
    【解决方案2】:

    我从 pom.xml 中删除了插件声明(据了解它是针对以前版本的 Selenium),安装了 xauth(不确定是否有必要),一切都开始工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-16
      • 1970-01-01
      • 1970-01-01
      • 2016-04-16
      • 1970-01-01
      • 2012-04-09
      • 2011-09-15
      相关资源
      最近更新 更多