从jenkins运行时,浏览器不会自动启动

时间:2016-02-05 09:21:51

标签: selenium jenkins

我正在从Jenkins执行selenium测试用例。我也想运行UI测试用例。但是当Jenkins构建时,浏览器不会启动。我正在使用Cent OS和FireFox。路径指定如下。

堆栈跟踪

org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/lib64/firefox/firefox) on port 7055; process output follows: 
Error: cannot open display: :99
Error: cannot open display: :99

Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35'
System info: host: 'nila.ejyothi.net', ip: '192.168.202.35', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-229.20.1.el7.x86_64', java.version: '1.7.0_91'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:130)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
    at com.fetchinglife.application.modules.utilities.CommonFunctions.initBrowser(CommonFunctions.java:74)
    at com.fetchinglife.application.modules.employee.EmployeeScheduleFunctionalTest.StartBrowser_NavURL(EmployeeScheduleFunctionalTest.java:34)
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:
Error: cannot open display: :99
Error: cannot open display: :99

    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
Standard

请给我一个解决方案?

1 个答案:

答案 0 :(得分:-1)

需要在客户端和服务器端启用X11转发。

在客户端,ssh的-X(大写X)选项启用X11转发,你可以在〜/ .ssh / config中使用ForwardX11 yes将其设置为默认值(对于所有连接或特定连接)。

在服务器端,必须在/ etc / ssh / sshd_config中指定X11Forwarding yes。请注意,默认情况下不转发(某些发行版在默认的/ etc / ssh / sshd_config中打开它),并且用户无法覆盖此设置。

必须在服务器端安装xauth程序。如果那里有任何X11程序,xauth很可能会在那里。在不太可能的情况下,xauth安装在非标准位置,可以通过〜/ .ssh / rc调用它(在服务器上!)。

请注意,您无需在服务器上设置任何环境变量。 DISPLAY和XAUTHORITY将自动设置为正确的值。如果您运行ssh并且未设置DISPLAY,则表示ssh未转发X11连接。

要确认ssh正在转发X11,请在ssh -v -X输出中检查包含请求X11转发的行。请注意,服务器不会以任何方式回复。

https://askubuntu.com/questions/523677/error-cannot-open-display-0-0-while-starting-remotelly-firefox

相关问题