Jenkins用户无法运行selenium测试:无法打开显示,没有指定协议(Ubuntu 11.04)

时间:2016-01-04 13:45:07

标签: java linux firefox selenium jenkins

我目前正试图让詹金斯进行我写过的硒测试。 如果我在命令行中使用我的用户执行jar文件,它可以工作:Firefox打开并且我在脚本中定义的操作正在进行,但是当我以jenkins-user身份登录并执行jar时,我收到以下错误:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
No protocol specified
No protocol specified
Error: cannot open display: :0
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:122)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:117)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
    at com.example.tests.test_login_logout.setUp(test_login_logout.java:24)
    at com.example.tests.test_login_logout.testLoginLogout(test_login_logout.java:40)
    at com.example.tests.test.main(test.java:8)
Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/bin/firefox-bin) on port 7055; process output follows: 
No protocol specified
No protocol specified
Error: cannot open display: :0
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: 'CAPSIDT410', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-97-generic', java.version: '1.7.0_91'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:134)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:117)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
    at com.example.tests.test_login_logout.setUp(test_login_logout.java:24)
    at com.example.tests.test_login_logout.testLoginLogout(test_login_logout.java:40)   at com.example.tests.test.main(test.java:8)
Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
No protocol specified
No protocol specified
Error: cannot open display: :0
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:122)
    ... 9 more

我已经尝试添加Xvfb,更改了displayname,检查了我有最新版本的Firefox和Selenium-server,将我的Firefox降级到以前的版本,但没有解决问题。

我怀疑这与jenkins不是普通用户而是&#34;服务用户&#34;这一事实有关。代替。我只能通过命令行使用此用户登录,并且只有在我修改用户后才需要密码。

如何让这个测试与Jenkins一起使用?

0 个答案:

没有答案