Skip to content

[πŸ› Bug]: Timeout creating webdriver.Chrome for chrome opened a while agoΒ #14906

@sinall

Description

@sinall

What happened?

Creating webdriver.Chrome timeouts if chrome already opened with 2 tabs and stays several minutes.

How can we reproduce the issue?

  1. Open chrome with command "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="D:\Downloads\selenium\profile" --disable-backgrounding-occluded-windows --disable-gpu --no-sandbox --start-maximized

  2. Open 2 tabs

  3. Leave chrome inactive for several minutes

  4. Run script

chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
chrome_options.set_capability("goog:loggingPrefs", {"performance": "ALL"})

driver_path = 'C:\\Program Files\\chromedriver-win64\\chromedriver.exe'

service = Service(executable_path=driver_path, port=9515)
driver = webdriver.Chrome(service=service, options=chrome_options)
  1. It will timeout at last line

  2. However if I switch to the inactive tab, the tab will refresh, and then above code runs without timeout.

Relevant log output

Traceback (most recent call last):
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\lenovo\anaconda3\lib\http\client.py", line 1347, in getresponse
    response.begin()
  File "C:\Users\lenovo\anaconda3\lib\http\client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "C:\Users\lenovo\anaconda3\lib\http\client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Users\lenovo\anaconda3\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\lenovo\anaconda3\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "C:\Users\lenovo\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 241, in __init__
    self.start_session(capabilities)
  File "C:\Users\lenovo\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 329, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "C:\Users\lenovo\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 382, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Users\lenovo\anaconda3\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 404, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Users\lenovo\anaconda3\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 428, in _request
    response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout)
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\request.py", line 78, in request
    return self.request_encode_body(
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\request.py", line 170, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\poolmanager.py", line 375, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\util\retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\packages\six.py", line 735, in reraise
    raise value
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 447, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "C:\Users\lenovo\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 336, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=9515): Read timed out. (read timeout=120)

Operating System

Windows 10

Selenium version

selenium-4.27.1, Python 3.8.8

What are the browser(s) and version(s) where you see this issue?

Chrome 131.0.6778.109

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 114.0.5735.90

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions