-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[py] Configure WebSocket timeout and wait interval via ClientConfig #16248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
@@ -1211,7 +1212,9 @@ def start_devtools(self): | |||
return self._devtools, self._websocket_connection | |||
if self.caps["browserName"].lower() == "firefox": | |||
raise RuntimeError("CDP support for Firefox has been removed. Please switch to WebDriver BiDi.") | |||
self._websocket_connection = WebSocketConnection(ws_url) | |||
self._websocket_connection = WebSocketConnection( | |||
ws_url, self.client_config.websocket_timeout, self.client_config.websocket_interval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ws_url, self.client_config.websocket_timeout, self.client_config.websocket_interval | |
ws_url, | |
self.command_executor.client_config.websocket_timeout, | |
self.command_executor.client_config.websocket_interval, |
All BiDi tests are failing because of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll take a look and fix it... I didn't see anywhere else in the code this was getting called, but I must have missed something.
@@ -1260,7 +1263,9 @@ def _start_bidi(self): | |||
else: | |||
raise WebDriverException("Unable to find url to connect to from capabilities") | |||
|
|||
self._websocket_connection = WebSocketConnection(ws_url) | |||
self._websocket_connection = WebSocketConnection( | |||
ws_url, self.client_config.websocket_timeout, self.client_config.websocket_interval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ws_url, self.client_config.websocket_timeout, self.client_config.websocket_interval | |
ws_url, | |
self.command_executor.client_config.websocket_timeout, | |
self.command_executor.client_config.websocket_interval, |
Same here
I think we should also add a test that actually modifies the timeout in addition to asserting default values test. |
sure... I'll add another test |
User description
🔗 Related Issues
#16270
💥 What does this PR do?
This PR allows the values for WebSocket timeout and wait interval to be set via the
ClientConfig
class in theselenium.webdriver.remote.client_config
module.The class initializer is also where the default values are stored. Previously the values were set in private attributes in the
WebSocketConnection
class and not easily configurable by the user.These settings are used for browser communication via WebSockets for both BiDi and CDP.
example usage:
setting the WebSocket timeout and wait interval on an existing local WebDriver:
starting a remote WebDriver using a custom
ClientConfig
that sets the WebSocket timeout and wait interval:🔗 Related Issues
Fixes #16260
🔧 Implementation Notes
This follows the implementation discussed in the 08/21/2025 Selenium TLC call.
🔄 Types of changes
PR Type
Enhancement
Description
Add WebSocket timeout and interval configuration to
ClientConfig
Update
WebSocketConnection
to accept configurable timeout/interval parametersEnable WebSocket settings for both BiDi and CDP communication
Minor documentation formatting improvements
Diagram Walkthrough
File Walkthrough
client_config.py
Add WebSocket configuration properties
py/selenium/webdriver/remote/client_config.py
websocket_timeout
andwebsocket_interval
properties withdescriptors
defaults
webdriver.py
Pass WebSocket config to connections
py/selenium/webdriver/remote/webdriver.py
start_devtools()
to pass WebSocket config fromclient_config
_start_bidi()
to pass WebSocket config fromclient_config
websocket_connection.py
Accept configurable timeout and interval
py/selenium/webdriver/remote/websocket_connection.py