I am using a very complex setup to test various non-public webpages. I use jenkins
to run the python-selenium
tests within a docker
image. That way, I am completly independent of the jenkins environment and can create my own environment. In this environment I have the following software installed:
- Firefox: 57.0.1
- geckodriver: 0.18.0
- nosetests: 1.3.7
- selenium: 3.8.0
The selenium tests create the WebDriver
the following way:
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.dir", self.downloadpath)
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.useDownloadDir", True)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("pdfjs.disabled", True)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk",
"application/force-download, image/png, text/html, text/plain, "
"image/tiff, text/csv, application/zip, application/octet-stream")
profile.set_preference("browser.download.manager.alertOnEXEOpen", False)
profile.set_preference("browser.download.manager.focusWhenStarting", False)
profile.set_preference("browser.helperApps.alwaysAsk.force", False)
profile.set_preference("browser.download.manager.alertOnEXEOpen", False)
profile.set_preference("browser.download.manager.closeWhenDone", True)
profile.set_preference("browser.download.manager.showAlertOnComplete", False)
profile.set_preference("browser.download.manager.useWindow", False)
profile.set_preference("services.sync.prefs.sync.browser.download.manager.showWhenStarting",
False)
self.driver = webdriver.Firefox(profile, log_path = logfile)
where logfile
and self.downloadpath
are two valid paths in the docker setup.
The whole test suite consists of 6 independant test cases, each with the same setup as above. They normally run fine and complete without problems.
But without any change to the tests or the general setup, a test sometimes fails with the following error message:
File "/root/tests/bsp_usecase_tests/tools/basicsuite.py", line 210, in set_driver_firefox
self.driver = webdriver.Firefox(profile, log_path = logfile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 158, in __init__
keep_alive=True)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 311, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: connection refused
I have two questions:
- What connection is refused here? What is the meaning of the error message
- How can I possibly fix this error?
Addendum:
- When I used a
time.sleep(10)
just before the webdriver.Firefox
line, the error did not show up anymore. Shoud I put that line in a while-try-except loop?
Question&Answers:
os