I have a selenium webdriver test, converted to maven project, that I want to run via xvfb on Jenkins.
There is a problem with display selection, but I would like to try something else and change the port, for example.
This is the error I get:
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
Error: no display specified
And this is my code:
File ffExe = new File("/usr/bin/firefox");
FirefoxBinary ffox = new FirefoxBinary(ffExe);
ffox.setEnvironmentProperty("DISPLAY", ":21");
WebDriver driver = new FirefoxDriver(ffox, null);
So, how can I tell firefox to use another port and which one should I specify?
The problem is not that it can't connect on that port, but rather the second part of the error, that there is no display specified in Jenkins. That's why setting the display for Firefox is probably not working.
Find out what your display settings are by typing env
in the terminal and taking down the number assigned to your DISPLAY variable. For example DISPLAY:1.0
.
Next you need to set the display variable in Hudson/Jenkins. Navigate to the Jenkins landing page then click Manage Jenkins>Manage Nodes>Master>Configure. Check the Environment variables check box, then set DISPLAY
in the name box, and the value to something like our example :1.0
.
Additionally you'll probably need to disable your xhost access controls using xhost +
in the terminal.
There is a System property -webdriver.firefox.port which could be the answer for yoru query. It is listed on the wiki - http://code.google.com/p/selenium/wiki/FirefoxDriver, but there is no documentaion provided for the same. You can try and let us know if it works :)
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