我想在没有显示器的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
答案 0 :(得分:1)
错误消息告诉您已经在显示号码1上运行了X服务器。根据您的说法:
我安装了x11-fonts *,xvfb,firefox,解压后的DISPLAY = localhost:1,启动了xvfb ...我添加了以下插件
似乎你启动了一个服务器,然后插件试图再次启动它(应该如此)。我会先尝试不启动xvfb(确保它不会运行)。
或者完全摆脱插件配置中的显示号码,它会尝试找到一个免费的显示号码。但是,它不会使用您的 xvfb实例。
答案 1 :(得分:1)
我从pom.xml中删除了插件声明(只要知道它是以前版本的Selenium),安装了xauth(不确定是否必要)并且一切都开始工作了。