Skip to content

[🚀 Feature]: [py] Add property for RemoteConnection.client_config so it's part of the public API #15672

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

Closed
cgoldberg opened this issue Apr 27, 2025 · 2 comments · Fixed by #15674
Labels
I-enhancement Something could be better

Comments

@cgoldberg
Copy link
Contributor

cgoldberg commented Apr 27, 2025

Description

There are many methods and attributes in the RemoteConnection class inside py/selenium/webdriver/remote/remote_connection.py that are marked as deprecated, and produce a warning like:

"DeprecationWarning: set_timeout() in RemoteConnection is deprecated, set timeout to ClientConfig instance in constructor instead."

However, AFAICT there is no way to pass a ClientConfig to any of the webdriver constructors except webdriver.Remote.

On a remote WebDriver, you can do:

from selenium import webdriver
from selenium.webdriver.remote.client_config import ClientConfig

client_config = ClientConfig(remote_server_addr="http://localhost:4444/", timeout=10)
options = webdriver.ChromeOptions()
driver = webdriver.Remote(options=options, client_config=client_config)

... which is pretty ugly. Local webdrivers don't accept a client_config argument, so this doesn't work for them. The other drawback of setting it in the constructor is that it doesn't allow you to change any settings in ClientConfig after creating the driver.

Possible Solution:

There is a _client_config attribute on the RemoteConnection class. If we create a client_config property, it would be part of the public API and allow you to set attributes on it after driver creation.

You could do this:

driver.command_executor.client_config.timeout = 10

to summarize, I suggest we:

  • add client_config as a @property that returns self._client_config
  • update all the deprecation messages to suggest using this instead of what they say now

Have you considered any alternatives or workarounds?

No response

@cgoldberg cgoldberg added A-needs-triaging A Selenium member will evaluate this soon! I-enhancement Something could be better labels Apr 27, 2025
@selenium-ci
Copy link
Member

@cgoldberg, thank you for creating this issue. We will troubleshoot it as soon as we can.

Selenium Triage Team: remember to follow the Triage Guide

@Pikamander2
Copy link

Thanks for making this ticket, Corey. Reposting my use case from #15604 here in case it's helpful:

Occasionally, I deal with web pages that have absurdly long page generation times that I have no control over. By default, Selenium's read timeout is 120 seconds, which isn't always long enough.

Here's a Python function that I've been using to dynamically increase/decrease the timeout from 120 seconds to whatever amount of time I need:

def change_selenium_read_timeout(driver, seconds):
    driver.command_executor.set_timeout(seconds)

Here's an example of how I use it:

change_selenium_read_timeout(driver, 5000)
driver.get(slow_url)
change_selenium_read_timeout(driver, 120)

My function works correctly, but throws a deprecation warning:

DeprecationWarning: set_timeout() in RemoteConnection is deprecated, set timeout to ClientConfig instance in constructor instead

The warning recommends changing the timeout value in the constructor, but for a true 1:1 replacement, we would need a simple way to change the timeout after the driver has already been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-enhancement Something could be better
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants