Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 含硒xvfb。显示器已在使用中。错误_Java_Linux_Selenium_Headless_Xvfb - Fatal编程技术网

Java 含硒xvfb。显示器已在使用中。错误

Java 含硒xvfb。显示器已在使用中。错误,java,linux,selenium,headless,xvfb,Java,Linux,Selenium,Headless,Xvfb,我想在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 我安装了x1

我想在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、extracted 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,但得到:

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

错误消息告诉您1号显示器上已经有一台X服务器在运行。从你所说的:

我安装了x11 fonts*、xvfb、firefox、extracted DISPLAY=localhost:1、启动了xvfb。。。我添加了以下插件

似乎您启动了一台服务器,然后插件又试图再次启动它(它应该这样做)。我会尽量避免事先启动xvfb(确保它不会运行)


或者完全去掉插件配置中的显示号码,它将尝试找到一个免费的显示号码。不过,它不会使用您的xvfb实例。

我从pom.xml中删除了插件声明(据我所知,它适用于早期版本的Selenium),安装了xauth(不确定这是否必要)一切都开始工作。

当我没有启动xvfb时,我遇到了这个错误:执行goal org.codehaus.mojo:selenium maven插件的xvfb:2.3:xvfb失败:执行失败:java.io.IOException:无法运行程序“xauth”:java.io.IOException:error=2,没有这样的文件或directory@DmitriySukharev:这意味着它找不到
xauth
。它应该位于
/usr/bin/xauth
(请检查!),如果找不到它,则路径可能有问题。无论如何,您可以在中指定可执行文件的路径。或者完全禁用xauth,如果有帮助的话。禁用xauth没有帮助。好啊我发现这个插件适用于早期版本的Selenium,即使没有xvfb,新的Selenium也可以正常工作。但我无法让它工作,我得到“org.openqa.selenium.firefox.NotConnectedException:45000毫秒后无法连接到端口7055上的主机127.0.0.1。firefox控制台输出:错误:无法打开显示:localhost:1”。也许你知道怎么解决吗?@DmitriySukharev从上面的评论中你的问题成功了吗?我也曾遇到过类似的问题,并努力让它发挥作用:)Tomasz Dziurko,我在一年前就让它发挥作用了(见我在2012年6月15日5:09的这个主题中的答案)。
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