google chrome - Python Selenium connection timeout issues - Stack Overflow

Running into a timeout issue with starting a python selenium chrome script and trying to get to at leas

Running into a timeout issue with starting a python selenium chrome script and trying to get to at least 'about:blank'. The browser opens up 'data:,' and just hangs up. The script:

from selenium import webdriver
import chromedriver_binary
from selenium.webdriver.chrome.service import Service

print(chromedriver_binary.chromedriver_filename)
print('----Start of Script----')
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_argument('--allow-insecure-localhost')
service = Service(service_args=['--log-level=DEBUG'], log_output='F:\App\Pysel\chromedriver.log')

# Initialize the Chrome WebDriver
print('----Options Created----')
driver = webdriver.Chrome(service=service, options=options)
print('----driver loaded----')
# Open a blank page
driver.get('about:blank')

The output that we get is:

(pysel_test) F:\App\Pysel>python conda_test.py
F:\App\Pysel\conda_test.py:18: SyntaxWarning: invalid escape sequence '\A'
  service = Service(service_args=['--log-level=DEBUG'], log_output='F:\App\Pysel\chromedriver.log')
C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\chromedriver_binary\chromedriver.exe
----Start of Script----
----Options Created----
Exception managing chrome: error sending request for url (.json)

DevTools listening on ws://127.0.0.1:54978/devtools/browser/913683e6-f64c-4141-9c14-4af941ff2bfa
Created TensorFlow Lite XNNPACK delegate for CPU.
Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors (tensor#-1 is a dynamic-sized tensor).
Traceback (most recent call last):
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 534, in _make_request
    response = conn.getresponse()
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connection.py", line 516, in getresponse
    httplib_response = super().getresponse()
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\http\client.py", line 1430, in getresponse
    response.begin()
    ~~~~~~~~~~~~~~^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\http\client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ~~~~~~~~~~~~~~~~~^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\http\client.py", line 292, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
               ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\socket.py", line 719, in readinto
    return self._sock.recv_into(b)
           ~~~~~~~~~~~~~~~~~~~~^^^
TimeoutError: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "F:\App\Pysel\conda_test.py", line 23, in <module>
    driver = webdriver.Chrome(service=service, options=options)
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__
    super().__init__(
    ~~~~~~~~~~~~~~~~^
        browser_name=DesiredCapabilities.CHROME["browserName"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        keep_alive=keep_alive,
        ^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 250, in __init__
    self.start_session(capabilities)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 342, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 427, in execute
    response = selfmand_executor.execute(driver_command, params)
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\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\Vince.Lepatan\.conda\envs\pysel_test\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\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\_request_methods.py", line 143, in request
    return self.request_encode_body(
           ~~~~~~~~~~~~~~~~~~~~~~~~^
        method, url, fields=fields, headers=headers, **urlopen_kw
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\_request_methods.py", line 278, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\poolmanager.py", line 443, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 841, in urlopen
    retries = retries.increment(
        method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
    )
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\util\retry.py", line 474, in increment
    raise reraise(type(error), error, _stacktrace)
          ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\util\util.py", line 39, in reraise
    raise value
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    response = self._make_request(
        conn,
    ...<10 lines>...
        **response_kw,
    )
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 367, in _raise_timeout
    raise ReadTimeoutError(
        self, url, f"Read timed out. (read timeout={timeout_value})"
    ) from err
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=54970): Read timed out. (read timeout=120)

It doesn't get pass the driver loading portion

We've tried looking into the logs and doesn't seem to help what the issue is but the last line in the logs says: 1742835183.073][DEBUG]: DevTools WebSocket Response: (id=3) (session_id=) browser {"code":-32001,"message":"Session with given id not found."}

Running into a timeout issue with starting a python selenium chrome script and trying to get to at least 'about:blank'. The browser opens up 'data:,' and just hangs up. The script:

from selenium import webdriver
import chromedriver_binary
from selenium.webdriver.chrome.service import Service

print(chromedriver_binary.chromedriver_filename)
print('----Start of Script----')
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_argument('--allow-insecure-localhost')
service = Service(service_args=['--log-level=DEBUG'], log_output='F:\App\Pysel\chromedriver.log')

# Initialize the Chrome WebDriver
print('----Options Created----')
driver = webdriver.Chrome(service=service, options=options)
print('----driver loaded----')
# Open a blank page
driver.get('about:blank')

The output that we get is:

(pysel_test) F:\App\Pysel>python conda_test.py
F:\App\Pysel\conda_test.py:18: SyntaxWarning: invalid escape sequence '\A'
  service = Service(service_args=['--log-level=DEBUG'], log_output='F:\App\Pysel\chromedriver.log')
C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\chromedriver_binary\chromedriver.exe
----Start of Script----
----Options Created----
Exception managing chrome: error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json)

DevTools listening on ws://127.0.0.1:54978/devtools/browser/913683e6-f64c-4141-9c14-4af941ff2bfa
Created TensorFlow Lite XNNPACK delegate for CPU.
Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors (tensor#-1 is a dynamic-sized tensor).
Traceback (most recent call last):
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 534, in _make_request
    response = conn.getresponse()
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connection.py", line 516, in getresponse
    httplib_response = super().getresponse()
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\http\client.py", line 1430, in getresponse
    response.begin()
    ~~~~~~~~~~~~~~^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\http\client.py", line 331, in begin
    version, status, reason = self._read_status()
                              ~~~~~~~~~~~~~~~~~^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\http\client.py", line 292, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
               ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\socket.py", line 719, in readinto
    return self._sock.recv_into(b)
           ~~~~~~~~~~~~~~~~~~~~^^^
TimeoutError: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "F:\App\Pysel\conda_test.py", line 23, in <module>
    driver = webdriver.Chrome(service=service, options=options)
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__
    super().__init__(
    ~~~~~~~~~~~~~~~~^
        browser_name=DesiredCapabilities.CHROME["browserName"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        keep_alive=keep_alive,
        ^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 250, in __init__
    self.start_session(capabilities)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 342, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 427, in execute
    response = selfmand_executor.execute(driver_command, params)
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\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\Vince.Lepatan\.conda\envs\pysel_test\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\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\_request_methods.py", line 143, in request
    return self.request_encode_body(
           ~~~~~~~~~~~~~~~~~~~~~~~~^
        method, url, fields=fields, headers=headers, **urlopen_kw
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\_request_methods.py", line 278, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\poolmanager.py", line 443, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 841, in urlopen
    retries = retries.increment(
        method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
    )
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\util\retry.py", line 474, in increment
    raise reraise(type(error), error, _stacktrace)
          ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\util\util.py", line 39, in reraise
    raise value
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    response = self._make_request(
        conn,
    ...<10 lines>...
        **response_kw,
    )
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 536, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vince.Lepatan\.conda\envs\pysel_test\Lib\site-packages\urllib3\connectionpool.py", line 367, in _raise_timeout
    raise ReadTimeoutError(
        self, url, f"Read timed out. (read timeout={timeout_value})"
    ) from err
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=54970): Read timed out. (read timeout=120)

It doesn't get pass the driver loading portion

We've tried looking into the logs and doesn't seem to help what the issue is but the last line in the logs says: 1742835183.073][DEBUG]: DevTools WebSocket Response: (id=3) (session_id=) browser {"code":-32001,"message":"Session with given id not found."}

Share Improve this question asked Mar 24 at 17:06 user30045647user30045647 1
Add a comment  | 

1 Answer 1

Reset to default 0

Keep thing simple! - Remember Selenium is being used successfully by millions of others worldwide.

The main issues will always be your setup or configuration of Selenium or local network connection.

  1. First remove all the chrome arguments you put and use the default and standard way of using Selenium without any options. Use ChatGPT or AI chat bot to give you a basic and simple script in python.

  2. Then modify it to use against your website

  3. Look at the error you get on the browser and if its network related due to certificates then you can add in the arguments for the browser. Again use ChatGPT or AI chat bot to give you this basic addition.

  4. If that still doesn't work then you need to look at the LAN settings of your local machine and get it resolved. It could be due to corrupt or non-existing proxy settings

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744238337a4564581.html

相关推荐

  • google chrome - Python Selenium connection timeout issues - Stack Overflow

    Running into a timeout issue with starting a python selenium chrome script and trying to get to at leas

    8天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信