-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed
Description
Background:
- Under Linux and Windows, bind()-ing to network port 0 assigns the application a free port from the dynamic port range.
Test setup:
- Selenium server standalone version 2.48.2
- CentOS 7
- Java 1.7.0_91
- Firefox 38.3.0
Issue description:
- When launching multiple Selenium instances on "HtmlSuites" it can be very useful for a user to be able to set the option
-port 0
. This would allow the Selenium application to receive a free port from the OS, removing the burden of finding one from the user's shoulders. - The tested Selenium server accepts
-port 0
option and will correctly listen on the random free port offered by the OS, as can be seen vialsof
. - The automatically generated configuration files for the browser (here: Firefox) do not reflect this assigned port but reference the port set via command-line: 0.
Example:
Selenium command used, i.e. with your own favourite HtmlSuite:
java -jar selenium-server-standalone.jar -port 0 -htmlSuite "*firefox" "http://some.url.ch/" "test_suite.html" "results.html"
Launching lsof -p <pID>
on the process ID will show the listening port:
[...]
java 9500 jenkins 11u IPv6 190573 0t0 TCP *:51276 (LISTEN)
[...]
When looking at the prefs.js
file generated for the Firefox instance, we can see that the URL wrongly references localhost:0 instead of localhost:51276 (URL %XX notation removed for readability):
[...]
user_pref("browser.startup.homepage", "chrome://src/content/TestRunner.html?auto=true&multiWindow=true&defaultLogLevel=info&baseUrl=http://some.url.ch/&resultsUrl=../postResults&test=http://localhost:0/selenium-server/tests/test_suite.html");
[...]
Possible resolution:
- I'm not a programmer but the Java socket documentation has a getLocalPort function which could be used to identify the effective port number on which Selenium is listening. This value should then override the command-line value.
This would really help in our current setup of Selenium test cases :-)
Kind regards,
Volker
Metadata
Metadata
Assignees
Labels
No labels