与Jenkins一起运行headless firefox Xvfb以运行selenium测试
我面临与Jenkins一起运行headless firefox Xvfb以运行selenium测试,selenium,firefox,jenkins,selenide,Selenium,Firefox,Jenkins,Selenide,我面临错误:在FreeBSD服务器上的Jenkins中运行play framework测试时,没有指定显示错误。 所以每次我面对超时 org.openqa.selenium.firefox.NotConnectedException:45000毫秒后无法连接到端口7055上的主机127.0.0.1。firefox 詹金斯: 1) 已安装Xvfb插件 2) 已安装播放框架 测试是使用selenide库和selenide play框架模块编写的 在作业配置中配置并启用了Xvfb 作业控制台输出为:
错误:在FreeBSD服务器上的Jenkins中运行play framework测试时,没有指定显示错误。
所以每次我面对超时
org.openqa.selenium.firefox.NotConnectedException:45000毫秒后无法连接到端口7055上的主机127.0.0.1。firefox
詹金斯:
1) 已安装Xvfb插件
2) 已安装播放框架
测试是使用selenide库和selenide play框架模块编写的
在作业配置中配置并启用了Xvfb
作业控制台输出为:
Checking out Revision 3f485bd2e3dbcfa058fc19f89ab18020e36707d8 (origin/trunk)
...
Xvfb starting$ /usr/local/bin//Xvfb :1 -screen 0 -fbdir /usr/local/jenkins/xvfb-9-786185694297443042.fbdir
...
Command detected: clean
Command detected: deps --sync
Command detected: precompile
Command detected: auto-test
[YalsTests] $ /srv/java/play/play clean
...
~ using java version "1.8.0_72"
[YalsTests] $ /srv/java/play/play auto-test
~ 14 tests to run:
~
~ selenium/front/CorrectInput... org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:113)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
作业配置:
[X] Start Xvfb before the build, and shut it down after.
Xvfb specific display name 1
Xvfb display name offset 0
Invoke Play Framework
Command set Play 1.x
Goals
Clean project [clean]
Custom parameter
Custom command deps --sync
Precompile all Java sources and templates [precompile]
Automatically run all application tests [auto-test]
selenium任务需要知道它应该连接到的显示器。
您可以将其设置为环境变量(如果在.profile中这样做,请不要忘记导出它)
对于bash,其他Shell可能需要两个步骤:
DISPLAY=:10
export DISPLAY
也可以在命令行中指定变量,然后再执行命令:
DISPLAY=:10 java -jar mySelenium.jar
通过使用在容器中并行启动无头浏览器的project,您可以避免所有这些问题。容器映像是通过考虑webdriver和浏览器的兼容版本创建的。它们还包括字体、flashplayer等。只需选择一个已经存在的测试并运行您的测试。运行Selenium测试不需要安装Java。“DISPLAY=:10java-jar mySelenium.jar”,我的问题是关于这个命令。这是用于网格执行的吗?如果我需要通过Jenkins在远程机器上对WebDriver执行测试,该怎么做?@Afsal也许这有帮助?因此,我们的想法是在Selenium代码中设置显示变量,并为Xvfb使用相同的显示编号。对吗?我用铬。我将在Chrome中检查类似的功能。
DISPLAY=:10 java -jar mySelenium.jar