Linux下的Jenkins裏配置Webdriver項目會碰到以下錯誤html
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:linux
Error: no display specifiedweb
Error: no display specifiedubuntu
主要是由於webdriver須要一個虛擬的GUI來運行瀏覽器, 查了網上的資料,大多數都說用Xvfb, 配置裏還須要有export DISPLAY=:1瀏覽器
但是我又碰到了新的錯誤即便配置了DISPLAYless
Error: cannot open display: :1ide
感受Xvfb使用比較麻煩,特別是個人機器還不是官方的Ubuntu, Red hat能夠參考下面兩篇文章ui
Running headless WebDriver tests with Firefox 10, Xvfb and Jenkins (all on RHEL 6)firefox
http://www.jpalomaki.fi/?p=403 server
Running headless webdriver based selenium junit tests inside jenkins under ubuntu linux
最後找到還有一個虛擬UI就是VNC, Jenkins XVnc Plugin,使用很是簡單,安裝後在項目的config裏勾選「Run Xvnc during build」就能夠了,
服務端安裝
sudo apt-get install vnc4server
# Now start the VNC server once as the jenkins user and give it a password,
# otherwise it'll try to ask Jenkins
sudo su jenkins
vncserver
[enter password: vncserver]
Ctrl-C
Testing with Selenium 2 / WebDriver, Firefox, Jenkins and Linux
http://fuzzydb.blogspot.tw/2011/08/testing-with-selenium-2-webdriver.html