Skip to content

Commit 746e213

Browse files
authored
Update Selenium RemoteConnection to use ClientConfig for timeout (#4027)
1 parent 84d97ec commit 746e213

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

changedetectionio/content_fetchers/webdriver_selenium.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,17 @@ def _run_sync():
104104

105105
from selenium.webdriver.remote.remote_connection import RemoteConnection
106106
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
107+
from selenium.webdriver.remote.client_config import ClientConfig
108+
from urllib3.util import Timeout
107109
driver = None
108110
try:
109-
# Create the RemoteConnection and set timeout (e.g., 30 seconds)
110-
remote_connection = RemoteConnection(
111-
self.browser_connection_url,
111+
connection_timeout = int(os.getenv("WEBDRIVER_CONNECTION_TIMEOUT", 90))
112+
client_config = ClientConfig(
113+
remote_server_addr=self.browser_connection_url,
114+
timeout=Timeout(connect=connection_timeout, total=connection_timeout)
112115
)
113-
remote_connection.set_timeout(30) # seconds
116+
remote_connection = RemoteConnection(client_config=client_config)
114117

115-
# Now create the driver with the RemoteConnection
116118
driver = RemoteWebDriver(
117119
command_executor=remote_connection,
118120
options=options

0 commit comments

Comments
 (0)