SeleniumHQ / selenium

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

[🐛 Bug]: OpenQA.Selenium.WebDriverException : disconnected: not connected to DevTools #14078

Open MJB222398 opened 4 weeks ago

MJB222398 commented 4 weeks ago

What happened?

Was running a series of tests (47) on the Chrome browser. After about 40 the browser suddenly and unexpectedly closed during a test. The exception presented to me was:

OpenQA.Selenium.WebDriverException : disconnected: not connected to DevTools (failed to check if window was closed: disconnected: not connected to DevTools) (Session info: chrome=125.0.6422.76)

Never seen this issue before, been using this version of selenium and chrome for a couple of weeks maybe, ran tests many times in this period.

Googling this exception the usual cause seems to be mismatching browser and driver versions. But that is not the case here, mine match.

How can we reproduce the issue?

Cannot reproduce it

Relevant log output

Logs from the Driver around the time it occurred:

2024-06-04 18:08:39.891 TRACE HttpCommandExecutor: << StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Cache-Control: no-cache
  Content-Length: 905
  Content-Type: application/json; charset=utf-8
}
2024-06-04 18:08:39.891 DEBUG HttpCommandExecutor: Response: ( NoSuchElement: System.Collections.Generic.Dictionary`2[System.String,System.Object])
2024-06-04 18:08:40.402 DEBUG HttpCommandExecutor: Executing command: [0b0c17a1d80bade8891e8a26ea683a28]: findElement {"using":"xpath","value":"//div[@class='ng-toast' or @class='modal-header text-danger']"}
2024-06-04 18:08:40.402 TRACE HttpCommandExecutor: >> Method: POST, RequestUri: 'http://localhost:4444/wd/hub/session/0b0c17a1d80bade8891e8a26ea683a28/element', Version: 1.1, Content: System.Net.Http.ByteArrayContent, Headers:
{
  Accept: application/json; charset=utf-8
  Content-Type: application/json; charset=utf-8
}
2024-06-04 18:08:40.414 TRACE HttpCommandExecutor: << StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Cache-Control: no-cache
  Content-Length: 905
  Content-Type: application/json; charset=utf-8
}
2024-06-04 18:08:40.414 DEBUG HttpCommandExecutor: Response: ( NoSuchElement: System.Collections.Generic.Dictionary`2[System.String,System.Object])
2024-06-04 18:08:40.914 DEBUG HttpCommandExecutor: Executing command: [0b0c17a1d80bade8891e8a26ea683a28]: findElement {"using":"xpath","value":"//div[@class='ng-toast' or @class='modal-header text-danger']"}
2024-06-04 18:08:40.914 TRACE HttpCommandExecutor: >> Method: POST, RequestUri: 'http://localhost:4444/wd/hub/session/0b0c17a1d80bade8891e8a26ea683a28/element', Version: 1.1, Content: System.Net.Http.ByteArrayContent, Headers:
{
  Accept: application/json; charset=utf-8
  Content-Type: application/json; charset=utf-8
}
2024-06-04 18:08:40.993 TRACE HttpCommandExecutor: << StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Cache-Control: no-cache
  Content-Length: 1169
  Content-Type: application/json; charset=utf-8
}
2024-06-04 18:08:40.993 DEBUG HttpCommandExecutor: Response: ( UnhandledError: System.Collections.Generic.Dictionary`2[System.String,System.Object])
2024-06-04 18:08:40.994 DEBUG HttpCommandExecutor: Executing command: [0b0c17a1d80bade8891e8a26ea683a28]: getPageSource {}
2024-06-04 18:08:40.994 TRACE HttpCommandExecutor: >> Method: GET, RequestUri: 'http://localhost:4444/wd/hub/session/0b0c17a1d80bade8891e8a26ea683a28/source', Version: 1.1, Content: <null>, Headers:
{
  Cache-Control: no-cache
}
2024-06-04 18:08:41.003 TRACE HttpCommandExecutor: << StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Cache-Control: no-cache
  Content-Length: 845
  Content-Type: application/json; charset=utf-8
}
2024-06-04 18:08:41.004 DEBUG HttpCommandExecutor: Response: ( UnhandledError: System.Collections.Generic.Dictionary`2[System.String,System.Object])

Logs from the chrome-node docker container:

2024-06-04 16:42:49,811 INFO Included extra file "/etc/supervisor/conf.d/chrome-cleanup.conf" during parsing
2024-06-04 16:42:49,811 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
2024-06-04 16:42:49,814 INFO RPC interface 'supervisor' initialized
2024-06-04 16:42:49,815 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2024-06-04 16:42:49,815 INFO supervisord started with pid 7
2024-06-04 16:42:50,817 INFO spawned: 'xvfb' with pid 729
2024-06-04 16:42:50,818 INFO spawned: 'vnc' with pid 732
2024-06-04 16:42:50,819 INFO spawned: 'novnc' with pid 736
2024-06-04 16:42:50,820 INFO spawned: 'selenium-node' with pid 739
2024-06-04 16:42:50,823 INFO success: selenium-node entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Appending Selenium options: --log-level CONFIG
Appending Selenium options: --session-timeout 180
Appending Selenium options: --heartbeat-period 30
Generating Selenium Config
Configuring server...
Setting up SE_NODE_HOST...
Setting up SE_NODE_PORT...
Tracing is disabled
Selenium Grid Node configuration: 
[events]
publish = "tcp://selenium-hub:4442"
subscribe = "tcp://selenium-hub:4443"

[node]
grid-url = "http://localhost:4444"
session-timeout = "180"
override-max-sessions = false
detect-drivers = false
drain-after-session-count = 0
max-sessions = 1

[[node.driver-configuration]]
display-name = "chrome"
stereotype = '{"browserName": "chrome", "browserVersion": "125.0", "platformName": "Linux", "goog:chromeOptions": {"binary": "/usr/bin/google-chrome"}}'
max-sessions = 1

Starting Selenium Grid Node...
16:42:51.499 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
16:42:51.503 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
16:42:51.601 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://selenium-hub:4442 and tcp://selenium-hub:4443
16:42:51.643 INFO [UnboundZmqEventBus.<init>] - Sockets created
2024-06-04 16:42:51,837 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-06-04 16:42:51,837 INFO success: vnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-06-04 16:42:51,837 INFO success: novnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
16:42:52.644 INFO [UnboundZmqEventBus.<init>] - Event bus ready
16:42:52.756 INFO [NodeServer.createHandlers] - Reporting self as: http://172.24.0.7:5555
16:42:52.774 INFO [NodeOptions.getSessionFactories] - Detected 12 available processors
16:42:52.830 INFO [NodeOptions.report] - Adding chrome for {"browserName": "chrome","browserVersion": "125.0","goog:chromeOptions": {"binary": "\u002fusr\u002fbin\u002fgoogle-chrome"},"platformName": "linux","se:noVncPort": 7900,"se:vncEnabled": true} 1 times
16:42:52.853 INFO [Node.<init>] - Binding additional locator mechanisms: relative
16:42:52.997 INFO [NodeServer$1.start] - Starting registration process for Node http://172.24.0.7:5555
16:42:52.998 INFO [NodeServer.execute] - Started Selenium node 4.21.0 (revision 79ed462ef4): http://172.24.0.7:5555
16:42:53.004 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
16:42:53.156 INFO [NodeServer.lambda$createHandlers$2] - Node has been added
.
.
.
.
.
.
.
.
.
17:07:00.679 INFO [LocalNode.newSession] - Session created by the Node. Id: 0b0c17a1d80bade8891e8a26ea683a28, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 125.0.6422.76, chrome: {chromedriverVersion: 125.0.6422.76 (67dcf7562b8f..., userDataDir: /home/seluser/selenium/profile}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:35139}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:bidiEnabled: false, se:cdp: ws://localhost:4444/session..., se:cdpVersion: 125.0.6422.76, se:vnc: ws://localhost:4444/session..., se:vncEnabled: true, se:vncLocalAddress: ws://172.24.0.7:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
17:07:00.688 INFO [ProxyNodeWebsockets.createWsEndPoint] - Establishing connection to ws://localhost:35139/devtools/browser/08d51bc4-7734-4b85-987b-a512921357d0
17:08:41.003 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "da21f2d34609710ddce6a5abb7127bd0","eventTime": 1717520921003094781,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.remote.http.Route$PredicatedRoute","http.host": "172.24.0.7:5555","http.method": "GET","http.request_content_length": "0","http.scheme": "HTTP","http.status_code": 500,"http.target": "\u002fsession\u002f0b0c17a1d80bade8891e8a26ea683a28\u002fsource","http.user_agent": "selenium\u002f4.21.0 (.net linux)"}}

17:08:43.078 INFO [SessionSlot.stop] - Stopping session 0b0c17a1d80bade8891e8a26ea683a28

Operating System

Ubuntu 20.04

Selenium version

.NET 4.21.0

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

Chrome 125.0.6422.76

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

Chromium 125.0.6422.76

Are you using Selenium Grid?

4.21.0-20240522

github-actions[bot] commented 4 weeks ago

@MJB222398, 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!

pujagani commented 4 weeks ago

Was this occurring in the previous versions of Chrome? As far as I understand, nothing is updated in the Grid regarding how the CDP connection is made. Maybe it is a Chrome issue.

MJB222398 commented 3 weeks ago

@pujagani I can't say it wasn't occurring in previous versions but if it was I didn't see it happen.

pujagani commented 3 weeks ago

Thank you for the update. We will need a way to reproduce this, otherwise triaging or fixing is not possible from our end. If you can help eliminate this in previous Chrome versions then we know it is the Chrome version used that might be the root cause.

github-actions[bot] commented 3 weeks ago

Hi, @MJB222398. 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.