Skip to content

Certain exceptions cause WebDriver to become unresponsive #6826

@Thenakedgun

Description

@Thenakedgun

🐛 Bug Report

Under certain circumstances when an Exception is thrown within Python in seemingly unrelated code, the Firefox/WebDriver instance becomes unresponsive & it is not possible to close open Firefox instances.

When called, driver.quit() returns None, but does not close the active Firefox instance. Additionally, driver.close() also doesn't close the browser instance & instead produces the following error:

urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=61067): Max retries exceeded with url: /session/5385f593-7782-4073-996e-b226f0e9dc4e/window (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000114A0CE05F8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))

If in the "Test Script" below, I enter either a valid or invalid URI, then the browser closes as expected. In the event of an invalid URI, selenium throws a selenium.common.exceptions.InvalidArgumentException, but this is caught & terminates normally. Similarly, if I replace the input statement with, raise KeyboardInterrupt() or raise EOFError() then the browser is also closed as expected.

Using pdb, the expected path of execution seems to be followed. I posted this on SO yesterday to see if I was just expecting / doing something incorrectly, but the post didn't get any bites: https://stackoverflow.com/questions/54069341/exception-prevents-webdriver-from-responding-properly

To Reproduce

Run the "Test Script" below; this example seems to be reflective of the issue I'm running into.

When prompted for input, rather the entering a string, press Ctrl+C to send the SIGINT. During the input statement on my machine, this raises an EOFError().

Expected behavior

Execution should be halted when the EOFError is raised & flow resumes at the except statement. It will then pass, and continues in the finally statement & the browser instance is closed by either driver.close() or driver.quit().

Test script or set of commands reproducing this issue

from selenium import webdriver
import pdb

try:
	#pdb.set_trace()
	driver = webdriver.Firefox(executable_path='./bin/geckodriver.exe')
	variable = input("Enter something or Ctrl+C: ")
	driver.get(variable)
except Exception as e:
	pass
finally:
	driver.close()
	driver.quit()

Within my real code environment, I've wrapped my script in a similar try except finally statement, and similarly, after certain exceptions are thrown in seemingly unrelated statements the driver object stops responding as expected. This seemed to be the minimum amount of code which produced the same error.

Environment

OS: Windows 10
Browser: Firefox
Browser version: 64.0
Browser Driver version: GeckoDriver v0.23.0
Language Bindings version: Python 3.6.4
Selenium Version: 3.141.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-pyPython BindingsJ-awaiting answerQuestion asked of user; a reply moves it to triage again

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions