I'm experimenting with running my RF/Selenium2Library tests from Jenkins on my OSX laptop. Jenkins is installed as default as user 'jenkins'. I have the RF plugin for Jenkins installed and environment variables set, and everything works fine EXCEPT the browser never opens (neither firefox nor chrome) and the tests fail with selenium timeouts saying that such and such element never appeared.
My hunch is that I need to set a display variable somewhere to get the browser to open properly.
Here's my 'execute shell' command from Jenkins for this project:
source /Users/Shared/Jenkins/.bash_profile; pybot -b /Users/Shared/Jenkins/robot_output/dbug.log -i SMOKE01 -d /Users/Shared/Jenkins/robot_output/ /Users/KWHome/Dev/PycharmProjects/BHI/Tests; exit 0
Again, Selenium seems to think a browser is open somewhere and waits for the initial elements to appear, but they never do because no browser is actually open. I'm a total Jenkins newbie, so huge thanks for any advice on understanding what's going on here.
ADDED:
Here's some output from the jenkins user dbug log created after a build from Jenkins:
20140719 21:28:23.914 - INFO - Opening browser 'firefox' to base url 'https://staging.azzi-mvconnects.com/'
20140719 21:28:27.273 - DEBUG - Opened browser with session id a2414ad7-f523-7441-8a54-dd5c68f4049b
20140719 21:28:27.274 - INFO - +----- END KW: Selenium2Library.Open Browser (3360)
20140719 21:28:27.274 - INFO - +----- START KW: Selenium2Library.Maximize Browser Window [ ]
20140719 21:28:27.415 - INFO - +----- END KW: Selenium2Library.Maximize Browser Window (141)
20140719 21:28:27.416 - INFO - +----- START KW: Selenium2Library.Wait Until Element Is Visible [ ${home_login_button} ]
20140719 21:28:32.500 - INFO - +------ START KW: Selenium2Library.Capture Page Screenshot [ ]
20140719 21:28:32.909 - INFO - </td></tr><tr><td colspan="3"><a href="selenium-screenshot-1.png"><img src="selenium-screenshot-1.png" width="800px"></a>
20140719 21:28:32.909 - INFO - +------ END KW: Selenium2Library.Capture Page Screenshot (409)
20140719 21:28:32.910 - FAIL - Element 'ctl00_LoginLink' was not visible in 5 seconds
The browser appears to have 'opened', but it never appears on the desktop. I tried putting 'DISPLAY=:0' before the command to run pybot but no change.
If your Jenkins job needs to run something that displays a GUI, you cannot run that build in Jenkins which runs as a background service (whether on Windows, Mac or Linux).
(In Linux you can play tricks with Xvnc or similar fake X servers and there are even Jenkins plugins that make it simpler.)
Your alternatives are either:
java -jar /path/to/jenkins.war. When Jenkins is started in the GUI context, any processes started by Jenkins are able to talk to the GUI system and draw windows.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With