Unable to start browser from Jenkins CI

倾然丶 夕夏残阳落幕 提交于 2019-12-01 23:11:37
modusAndrew

Someone else had a similar issue and the solution looked to be making sure you have a stable version of Capybara and latest selenium webdriver

unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)

Let me know if this solution helps!

It turns out the account nature of Jenkins user does not allow it to run GUI tests within the Jenkins server.

Firefox is a GUI application and it needs to connect to an X server to send its commands to draw windows and such. Usually Jenkins is set up to run as a background system daemon that has no access to any X server session.

This is the reason for below error when trying to launch firefox in a Jenkins build using shell command /usr/bin/firefox.

No protocol specified

XDG_RUNTIME_DIR not set in the environment

Error: cannot open display: :0

Hence a possible solution would be to use pkexec command to trigger the test with root privilege (it might be possible to add the Jenkins user to the sudo group such that it can run the commands successfully, but not recommended due to security concern, and I tried it didn't work).

To achieve full automation with pkexec needs some other settings, e.g. disable authentication prompts. I will update with a more detailed answer once I have the step-wise solution ready.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!