[🐛 Bug]: WebDriverException thrown with empty message when remote driver request returns an empty response with status code above 500 #15357
Labels
A-needs-triaging
A Selenium member will evaluate this soon!
I-defect
Something is not working as intended
What happened?
This error occurs when Selenium attempts to connect to the remote driver, but the response is empty with a status code above 500. I think that the remote driver itself might not return such status codes, but when the client machine is behind a proxy or in a restricted network (e.g., in corporate environments). In such cases, the proxy server or network firewall may return an empty response instead of forwarding the remote driver's response, or the request might simply time out.
Why WebDriverException has empty message ?
in _request function in py/selenium/webdriver/remote/remote_connection.py (around line 455)
The data.strip() method returns an empty string due to an empty response. Since the "status" is set to UNKNOWN_ERROR, the WebDriverException is selected, and the "value" field, which is empty, is assigned in the ErrorHandler around line 194 in py/selenium/webdriver/remote/errorhandler.py.
Core problem
This error is highly unlikely to occur because it only happens when an incorrect proxy setting is explicitly specified in Selenium.
By default, Selenium automatically picks up system-wide proxy settings if no proxy is specified in client_config.
However, on Windows, this issue is more likely to happen — here's why:
On Windows, system-wide proxy settings are configured via the Settings app (Internet Options) and stored in the registry, while Selenium only reads proxy settings from environment variables by default.
This behavior can be confusing because even though a proxy is configured system-wide, Selenium won't use it unless the environment variables are set. Without the proxy, driver request might return an empty response in corporate environments or restricted networks that require proxy usage.
What I would like to contribute
Error Message
Displaying an empty error message can be slightly inconvenient. It would be more helpful if the message included the status code, URL, and reason for the error.
Proxy Setting (Default Behavior)
On Windows, when the ProxyType is set to SYSTEM (the default value), it would be more convenient to automatically retrieve proxy settings from the registry. This can be achieved with the following simple code:
If proposes are suite this project, I would like to create PR for this
How can we reproduce the issue?
Relevant log output
Operating System
Windows 11
Selenium version
Python 4.29.0
What are the browser(s) and version(s) where you see this issue?
Google Chrome Version 133.0.6943.142 (Official Build) (64-bit)
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver-133.0.6943.141
Are you using Selenium Grid?
Yes
The text was updated successfully, but these errors were encountered: