我试图在CI服务器上build立一个Seleniumtesting(Jenkins)。 它运行在Centos 5上,没有显示器。 对于Seleniumtesting,我需要一种方法来运行Firefox,所以我已经安装了Xvfb。 我正在使用selenium-maven-plugin来启动Xvfb。
<profile> <id>xvfb-selenium</id> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>selenium-maven-plugin</artifactId> <version>2.0</version> <executions> <execution> <id>xvfb</id> <phase>pre-integration-test</phase> <goals> <goal>xvfb</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile>
它在一个configuration文件中,因为我想在CI上运行它,但是开发机器不需要它。
我再次使用selenium-maven-plugin来运行我的selenesetesting
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>selenium-maven-plugin</artifactId> <version>2.0</version> <executions> <execution> <id>nessos-selenium-tests</id> <phase>integration-test</phase> <configuration> <browser>*firefox</browser> <suite>src/test/resources/test-suite.html</suite> <startURL>${selenium.startURL}</startURL> </configuration> <goals> <goal>selenese</goal> </goals> </execution> </executions> </plugin>
现在当我尝试运行这个,我在Jenkins得到这个错误:
message : Selenium is already running on port 4444. Or some other service is. Stack trace : java.net.BindException: Selenium is already running on port 4444. Or some other service is. at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:410)
这并没有告诉我更多的调查。 在目标/selenium/ xvfb.log我有这个错误:
(EE) config/hal: NewInputDeviceRequest failed (2) (EE) config/hal: NewInputDeviceRequest failed (2) (EE) config/hal: NewInputDeviceRequest failed (2) (EE) config/hal: NewInputDeviceRequest failed (2) (EE) config/hal: NewInputDeviceRequest failed (2)
在这一点上,我很无能。 从maven日志中我可以看到,xvfb目标在selenese之前运行,输出如下:
Created dir: /home/jenkins/workspace/myBuild/target/selenium Launching Xvfb [INFO] Redirecting output to: /home/jenkins/workspace/myBuild/target/selenium/xvfb.log Waiting for Xvfb... Xvfb started
我试过按照这里的说明: http : //mojo.codehaus.org/selenium-maven-plugin/examples/headless-with-xvfb.html
我做了
chmod u+s `which Xvfb`
事情和错误消息更改为:
Fatal server error: PAM authentication failed, cannot start X server. Perhaps you do not have console ownership?
在headless-with-xvfb页面的底部有指导来解决这个问题。 我也这样做,现在我得到(EE) config/hal: NewInputDeviceRequest failed (2)了。
有谁知道我会如何继续debugging这个错误? 还是有人知道这个错误甚至意味着什么?
真的很尴尬:)它已经工作,错误信息可以忽略。 我的最终解决scheme是在集成前阶段使用插件启动xvfb,在集成testing阶段使用WebDriver API运行jUnittesting。 当Maven运行完成时,Xvfbclosures