SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.67k stars 8.19k forks source link

[🐛 Bug]: When I ask server A to execute an automated script on server B by selenium-grid,I cannot use Chrome DevTools Protocol #11142

Closed wkxLegend closed 2 years ago

wkxLegend commented 2 years ago

What happened?

When I ask server A to execute an automated script on server B by selenium-grid. I get an error.

File "/code/selenium_execute/debug.py", line 359, in fetch
    trio.run(f)
  File "/usr/local/sbin/python-3.8/lib/python3.8/site-packages/trio/_core/_run.py", line 1932, in run
    raise runner.main_task_outcome.error
  File "/code/selenium_execute/debug.py", line 331, in f
    async with execute_object.driver.bidi_connection() as connection:
  File "/usr/local/sbin/python-3.8/lib/python3.8/contextlib.py", line 171, in __aenter__
    return await self.gen.__anext__()
  File "/usr/local/sbin/python-3.8/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 1176, in bidi_connection
    version, ws_url = self._get_cdp_details()
  File "/usr/local/sbin/python-3.8/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 1199, in _get_cdp_details
    res = http.request('GET', f"http://{debugger_address}/json/version")
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=64459): Max retries exceeded with url: /json/version (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4c90401280>: Failed to establish a new connection: [Errno 111] Connection refused'))

Because of selenium-grid is used, The chrome browser runs on server B. this host should be the ip address of server B instead of the 'localhost' of server A. Therefore, I cannot call the Chrome DevTools Protocol of server B on server A

How can we reproduce the issue?

First, set server A as the Hub using selenium-grid

Second, set server B to node

Third, run selenium in python on server A and execute it on server B using RemoteDriver()

async with driver.bidi_connection() as connection

When you use the code above for connecting CDP, you will reproduce the issue

Relevant log output

No

Operating System

mac OS

Selenium version

Python selenium 4.4.0

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

Chrome 106

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

ChromeDriver 106

Are you using Selenium Grid?

Selenium Grid 3.141.0

github-actions[bot] commented 2 years ago

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


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] commented 2 years ago

Hi, @wkxLegend. Please follow the issue template, we need more information to reproduce the issue.

Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue.

Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough.

Reply to this issue when all information is provided, thank you.

diemol commented 2 years ago

I believe this is because you are using an old version of Selenium Grid. Please use the latest (4.5.0 at the moment of writing this), and if needed, set the --grid-url value in the Node.

If the issue still happens, please provide the information required by the template and we will reopen.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.