Unable to start browser from Jenkins CI

后端 未结 2 2075
迷失自我
迷失自我 2021-01-22 08:43

I am unable to start the browser on the CI server (localhost on Linux in my case) when triggering a cucumber test via invoking a rake task after build from Jenkins. Jenkins cons

相关标签:
2条回答
  • 2021-01-22 09:10

    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!

    0 讨论(0)
  • 2021-01-22 09:16

    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.

    0 讨论(0)
提交回复
热议问题