selenium测试失败:xvfb-run:错误:Xvfb无法启动

时间:2016-05-18 06:39:39

标签: php selenium ubuntu xvfb

我在phpuni-environment.conf文件中有selenium测试配置

[program:selenium]
command=xvfb-run java -Dwebdriver.firefox.bin=/usr/bin/firefox -jar /usr/share/selenium/selenium-server-standalone.jar
autostart=false ; selenium

[program:python-webserver]
command=python -m SimpleHTTPServer 8080
directory=. ; python-webserver
autostart=false ; python-webserver

[program:php-webserver]
command=php -S localhost:8080
directory=. ; php-webserver
autostart=false ; php-webserver

我通过流浪汉进行测试。每当我运行任何类型的测试时,我总是会收到此错误

xvfb-run: error: Xvfb failed to start

我找到了几个解决此错误的方法,我尝试了这个

command=xvfb-run --auto-servernum --server-num=1 java -Dwebdriver.firefox.bin=/usr/bin/firefox -jar /usr/share/selenium/selenium-server-standalone.jar

但我仍然得到同样的错误。我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

下面的代码启动XVFB服务器并在为java透视图编写的无头模式下进行测试。

应在CENTOS

下面的命令下运行

DISPLAY =:99 sudo java -jar /root/Seleniumfolder/selenium-server-standalone-2.50.0.jar -log /root/Seleniumfolder/SeleniumServer.log -host 127.0.0.1 -port 4444 -Dwebdriver.firefox.bin =" / USR /斌/火狐"