SeleniumHQ / selenium

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

[🐛 Bug]: Unable to run a test because driver cannot connect to DevTools #14245

Closed pirquessa closed 1 month ago

pirquessa commented 1 month ago

What happened?

I'm having an issue when trying to run my enterprise end to end tests. It was working well and it is no more the case, I can't understand why. The same test work for my collegues.

I've created a small code to reproduce quickly the issue that is not link to any professional data.

I'm currently using Unbuntu 22.04.4 LTS, Google Chrome 126.0.6478.126 and the matching chrome driver downloaded by Selenium.

ls -al ~/.cache/selenium/chromedriver/linux64
total 12
drwxrwxr-x 3 pirquessa pirquessa 4096 juil. 10 14:24 .
drwxrwxr-x 3 pirquessa pirquessa 4096 juil. 10 14:24 ..
drwxrwxr-x 2 pirquessa pirquessa 4096 juil. 10 14:24 126.0.6478.126

When I run ruby ./driver.rb, I get an error linked to connection with DevTools:

#0 0x637232177c7a <unknown>: disconnected: Unable to receive message from renderer (Selenium::WebDriver::Error::WebDriverError)
  (failed to check if window was closed: disconnected: not connected to DevTools)

How can we reproduce the issue?

Here is my `driver.rb` to reproduce the issue:

require 'selenium-webdriver'

driver = Selenium::WebDriver.for(:chrome)
driver.get 'https://selenium.dev'
driver.quit

### Relevant log output

```shell
#0 0x637232177c7a <unknown>: disconnected: Unable to receive message from renderer (Selenium::WebDriver::Error::WebDriverError)
  (failed to check if window was closed: disconnected: not connected to DevTools)
  (Session info: chrome=126.0.6478.126)
        from #1 0x637231e5ae2c <unknown>
        from #2 0x637231e421a6 <unknown>
        from #3 0x637231e41d85 <unknown>
        from #4 0x637231e3fcc6 <unknown>
        from #5 0x637231e401ca <unknown>
        from #6 0x637231e3ede1 <unknown>
        from #7 0x637231e46b43 <unknown>
        from #8 0x637231e3eb14 <unknown>
        from #9 0x637231e41a4d <unknown>
        from #10 0x637231e3fcc6 <unknown>
        from #11 0x637231e401ca <unknown>
        from #12 0x637231e3ede1 <unknown>
        from #13 0x637231e35f08 <unknown>
        from #14 0x637231e3eb14 <unknown>
        from #15 0x637231e3e3a2 <unknown>
        from #16 0x637231e3de3b <unknown>
        from #17 0x637231e5d172 <unknown>
        from #18 0x637231e2f5bf <unknown>
        from #19 0x637231e2f09f <unknown>
        from #20 0x637231ed6e5d <unknown>
        from #21 0x637231eca363 <unknown>
        from #22 0x637231e9a247 <unknown>
        from #23 0x637231e9ab9e <unknown>
        from #24 0x63723213e24b <unknown>
        from #25 0x6372321422f1 <unknown>
        from #26 0x637232129afe <unknown>
        from #27 0x637232142e52 <unknown>
        from #28 0x63723210e79f <unknown>
        from #29 0x637232167638 <unknown>
        from #30 0x637232167810 <unknown>
        from #31 0x637232176dac <unknown>
        from #32 0x7bebd6894ac3 <unknown>
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/response.rb:55:in `assert_ok'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/http/common.rb:101:in `new'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/http/common.rb:101:in `create_response'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/http/default.rb:103:in `request'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/http/common.rb:67:in `call'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/bridge.rb:635:in `execute'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/bridge.rb:76:in `create_session'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/common/driver.rb:323:in `block in create_bridge'
        from <internal:kernel>:90:in `tap'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/common/driver.rb:322:in `create_bridge'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/common/driver.rb:73:in `initialize'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/chrome/driver.rb:35:in `initialize'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/common/driver.rb:47:in `new'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/common/driver.rb:47:in `for'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver.rb:89:in `for'
        from ./driver.rb:4:in `<main>'

Operating System

Unbuntu 22.04.4 LTS

Selenium version

Ruby 3.3.4

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

Google Chrome 126.0.6478.126

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

Auto downloaded by Selenium ? Identified as 126.0.6478.126

Are you using Selenium Grid?

No response

github-actions[bot] commented 1 month ago

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

diemol commented 1 month ago

Where are you executing this code? Do you have a screen or window manager?

pirquessa commented 1 month ago

Where ? On my Ubuntu laptop. Do you have a screen or window manager? I don't understand what you're talking about :(

diemol commented 1 month ago

There are several issues open related to that error. A couple of them were due to an issue Selenium fixed a while ago, and the rest are issues in Chrome. Please check them, I believe yours should be there.

https://github.com/SeleniumHQ/selenium/issues?q=is%3Aissue+not+connected+to+DevTools+

pirquessa commented 1 month ago

I've seen the list, I didn't find any solution for me :(

diemol commented 1 month ago

Can you share the logs, maybe there is something there. Otherwise, you'd need to report it to the Chrome folks.

github-actions[bot] commented 1 month ago

We need more information about this issue in order to troubleshoot.

Please turn on logging and re-run your code. Information on how to adjust logs for your language can be found in our Troubleshooting documentation.

pirquessa commented 1 month ago

So I'me modified my script:

require 'selenium-webdriver'

logger = Selenium::WebDriver.logger
logger.level = :debug

driver = Selenium::WebDriver.for(:chrome)
driver.get 'https://selenium.dev'
driver.quit

I get

2024-07-10 16:28:14 INFO Selenium [:logger_info] Details on how to use and modify Selenium logger:
  https://selenium.dev/documentation/webdriver/troubleshooting/logging

2024-07-10 16:28:14 DEBUG Selenium [:selenium_manager] Selenium Manager binary found at /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/bin/linux/selenium-manager 
2024-07-10 16:28:14 DEBUG Selenium [:selenium_manager] Executing Process ["/home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/bin/linux/selenium-manager", "--browser", "chrome", "--language-binding", "ruby", "--output", "json", "--debug"] 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] Sending stats to Plausible: Props { browser: "chrome", browser_version: "", os: "linux", arch: "x86_64", lang: "ruby", selenium_version: "4.22-nightly" } 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] chromedriver not found in PATH 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] chrome detected at /usr/bin/google-chrome 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] Running command: /usr/bin/google-chrome --version 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] Output: "Google Chrome 126.0.6478.126 " 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] Detected browser: chrome 126.0.6478.126 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] Required driver: chromedriver 126.0.6478.126 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] chromedriver 126.0.6478.126 already in the cache 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] Driver path: /home/pirquessa/.cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver 
2024-07-10 16:28:18 DEBUG Selenium [:selenium_manager] Browser path: /usr/bin/google-chrome 
2024-07-10 16:28:18 DEBUG Selenium [:driver_service] Executing Process ["/home/pirquessa/.cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver", "--port=9515"] 
2024-07-10 16:28:18 DEBUG Selenium [:process] Starting process: ["/home/pirquessa/.cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver", "--port=9515"] with {[:out, :err]=>#<IO:<STDERR>>, :pgroup=>true} 
2024-07-10 16:28:18 DEBUG Selenium [:process]   -> pid: 1030539 
2024-07-10 16:28:18 DEBUG Selenium [:driver_service] polling for socket on ["127.0.0.1", 9515] 
Starting ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
2024-07-10 16:28:18 DEBUG Selenium [:command] -> POST session 
2024-07-10 16:28:18 DEBUG Selenium [:command]    >>> http://127.0.0.1:9515/session | {"capabilities":{"alwaysMatch":{"browserName":"chrome","goog:chromeOptions":{"binary":"/usr/bin/google-chrome"}}}} 
2024-07-10 16:28:18 DEBUG Selenium [:header]      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=UTF-8", "User-Agent"=>"selenium/4.22.0 (ruby linux)", "Content-Length"=>"114"} 
[1720621701,560][SEVERE]: Unable to receive message from renderer
2024-07-10 16:28:21 DEBUG Selenium [:header]    <<<  {"content-length"=>["1385"], "content-type"=>["application/json; charset=utf-8"], "cache-control"=>["no-cache"]} 
2024-07-10 16:28:21 DEBUG Selenium [:command] <- {"value":{"error":"disconnected","message":"disconnected: Unable to receive message from renderer\n  (failed to check if window was closed: disconnected: not connected to DevTools)\n  (Session info: chrome=126.0.6478.126)","stacktrace":"#0 0x565efdff6c7a \u003Cunknown>\n#1 0x565efdcd9e2c \u003Cunknown>\n#2 0x565efdcc11a6 \u003Cunknown>\n#3 0x565efdcc0d85 \u003Cunknown>\n#4 0x565efdcbecc6 \u003Cunknown>\n#5 0x565efdcbf1ca \u003Cunknown>\n#6 0x565efdcbdde1 \u003Cunknown>\n#7 0x565efdcc5b43 \u003Cunknown>\n#8 0x565efdcbdb14 \u003Cunknown>\n#9 0x565efdcc0a4d \u003Cunknown>\n#10 0x565efdcbecc6 \u003Cunknown>\n#11 0x565efdcbf1ca \u003Cunknown>\n#12 0x565efdcbdde1 \u003Cunknown>\n#13 0x565efdcb4f08 \u003Cunknown>\n#14 0x565efdcbdb14 \u003Cunknown>\n#15 0x565efdcbd3a2 \u003Cunknown>\n#16 0x565efdcbce3b \u003Cunknown>\n#17 0x565efdcdc172 \u003Cunknown>\n#18 0x565efdcae5bf \u003Cunknown>\n#19 0x565efdcae09f \u003Cunknown>\n#20 0x565efdd55e5d \u003Cunknown>\n#21 0x565efdd49363 \u003Cunknown>\n#22 0x565efdd19247 \u003Cunknown>\n#23 0x565efdd19b9e \u003Cunknown>\n#24 0x565efdfbd24b \u003Cunknown>\n#25 0x565efdfc12f1 \u003Cunknown>\n#26 0x565efdfa8afe \u003Cunknown>\n#27 0x565efdfc1e52 \u003Cunknown>\n#28 0x565efdf8d79f \u003Cunknown>\n#29 0x565efdfe6638 \u003Cunknown>\n#30 0x565efdfe6810 \u003Cunknown>\n#31 0x565efdff5dac \u003Cunknown>\n#32 0x7218bae94ac3 \u003Cunknown>\n"}} 
2024-07-10 16:28:21 DEBUG Selenium [:process] Checking if 1030539 is exited: 
2024-07-10 16:28:21 DEBUG Selenium [:process] Polling 20 seconds for exit of 1030539 
2024-07-10 16:28:21 DEBUG Selenium [:process] Checking if 1030539 is exited: 
2024-07-10 16:28:21 DEBUG Selenium [:process] Checking if 1030539 is exited: 
2024-07-10 16:28:21 DEBUG Selenium [:process]   -> exit code is 0 
2024-07-10 16:28:21 DEBUG Selenium [:process] Checking if 1030539 is exited: 
2024-07-10 16:28:21 DEBUG Selenium [:process]   -> exit code is 0 
2024-07-10 16:28:21 DEBUG Selenium [:process] Checking if 1030539 is exited: 
2024-07-10 16:28:21 DEBUG Selenium [:process]   -> exit code is 0 
#0 0x565efdff6c7a <unknown>: disconnected: Unable to receive message from renderer (Selenium::WebDriver::Error::WebDriverError)
  (failed to check if window was closed: disconnected: not connected to DevTools)
  (Session info: chrome=126.0.6478.126)
        from #1 0x565efdcd9e2c <unknown>
        from #2 0x565efdcc11a6 <unknown>
        from #3 0x565efdcc0d85 <unknown>
        from #4 0x565efdcbecc6 <unknown>
        from #5 0x565efdcbf1ca <unknown>
        from #6 0x565efdcbdde1 <unknown>
        from #7 0x565efdcc5b43 <unknown>
        from #8 0x565efdcbdb14 <unknown>
        from #9 0x565efdcc0a4d <unknown>
        from #10 0x565efdcbecc6 <unknown>
        from #11 0x565efdcbf1ca <unknown>
        from #12 0x565efdcbdde1 <unknown>
        from #13 0x565efdcb4f08 <unknown>
        from #14 0x565efdcbdb14 <unknown>
        from #15 0x565efdcbd3a2 <unknown>
        from #16 0x565efdcbce3b <unknown>
        from #17 0x565efdcdc172 <unknown>
        from #18 0x565efdcae5bf <unknown>
        from #19 0x565efdcae09f <unknown>
        from #20 0x565efdd55e5d <unknown>
        from #21 0x565efdd49363 <unknown>
        from #22 0x565efdd19247 <unknown>
        from #23 0x565efdd19b9e <unknown>
        from #24 0x565efdfbd24b <unknown>
        from #25 0x565efdfc12f1 <unknown>
        from #26 0x565efdfa8afe <unknown>
        from #27 0x565efdfc1e52 <unknown>
        from #28 0x565efdf8d79f <unknown>
        from #29 0x565efdfe6638 <unknown>
        from #30 0x565efdfe6810 <unknown>
        from #31 0x565efdff5dac <unknown>
        from #32 0x7218bae94ac3 <unknown>
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/response.rb:55:in `assert_ok'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/http/common.rb:101:in `new'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/http/common.rb:101:in `create_response'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/http/default.rb:103:in `request'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/http/common.rb:67:in `call'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/bridge.rb:635:in `execute'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/remote/bridge.rb:76:in `create_session'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/common/driver.rb:323:in `block in create_bridge'
        from <internal:kernel>:90:in `tap'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/common/driver.rb:322:in `create_bridge'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/common/driver.rb:73:in `initialize'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/chrome/driver.rb:35:in `initialize'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/common/driver.rb:47:in `new'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver/common/driver.rb:47:in `for'
        from /home/pirquessa/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.22.0/lib/selenium/webdriver.rb:89:in `for'
        from ./driver.rb:6:in `<main>'
sundeepsingh1984 commented 1 month ago

getting somthing similar all worked well till yesterday using centos

File "/home/sftpuser/tools/Efillings/chrome/TaxPortalAutomation.py", line 77, in init self.driver = webdriver.Chrome(options=self.options,keep_alive=True) File "/home/sftpuser/vevn/lib64/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in init super().init( File "/home/sftpuser/vevn/lib64/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in init super().init(command_executor=executor, options=options) File "/home/sftpuser/vevn/lib64/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in init self.start_session(capabilities) File "/home/sftpuser/vevn/lib64/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] File "/home/sftpuser/vevn/lib64/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute self.error_handler.check_response(response) File "/home/sftpuser/vevn/lib64/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally. (session not created: Devtools port number file contents <> were in an unexpected format) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

sundeepsingh1984 commented 1 month ago

more logs here

2024-07-11 22:39:04,809 - DEBUG - Selenium Manager binary found at: /home/sftpuser/vevn/lib64/python3.9/site-packages/selenium/webdriver/common/linux/selenium-manager 2024-07-11 22:39:04,809 - DEBUG - Executing process: /home/sftpuser/vevn/lib64/python3.9/site-packages/selenium/webdriver/common/linux/selenium-manager --browser chrome --debug --language-binding python --output json 2024-07-11 22:39:04,851 - DEBUG - Found chromedriver 126.0.6478.55 in PATH: /usr/local/bin/chromedriver 2024-07-11 22:39:04,852 - DEBUG - chrome detected at /usr/bin/google-chrome 2024-07-11 22:39:04,852 - DEBUG - Running command: /usr/bin/google-chrome --version 2024-07-11 22:39:04,852 - DEBUG - Output: "Google Chrome 126.0.6478.126 " 2024-07-11 22:39:04,852 - DEBUG - Detected browser: chrome 126.0.6478.126 2024-07-11 22:39:04,852 - DEBUG - Required driver: chromedriver 126.0.6478.126 2024-07-11 22:39:04,852 - DEBUG - Driver path: /usr/local/bin/chromedriver 2024-07-11 22:39:04,852 - DEBUG - Browser path: /usr/bin/google-chrome 2024-07-11 22:39:04,854 - DEBUG - Started executable: /usr/local/bin/chromedriver in a child process with pid: 1064396 using 0 to output -3 2024-07-11 22:39:04,867 - DEBUG - POST http://localhost:58989/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'chrome', 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'browserVersion': None, 'goog:chromeOptions': {'excludeSwitches': ['enable-automation'], 'useAutomationExtension': False, 'prefs': {'download.default_directory': '/home/sftpuser/tools/Efillings/DATA/GUIPS4704M', 'download.prompt_for_download': False, 'download.directory_upgrade': True, 'safebrowsing.enabled': True}, 'extensions': [], 'binary': '/usr/bin/google-chrome', 'args': ['user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', '--no-sandbox', '--disable-dev-shm-usage', '--disable-setuid-sandbox', '--disable-gpu', '--disable-blink-features=AutomationControlled', '--start-maximized', '--headless=new']}}}} 2024-07-11 22:39:04,868 - DEBUG - Starting new HTTP connection (1): localhost:58989 2024-07-11 22:39:06,383 - DEBUG - http://localhost:58989 "POST /session HTTP/11" 500 0 2024-07-11 22:39:06,383 - DEBUG - Remote response: status=500 | data={"value":{"error":"session not created","message":"session not created: Chrome failed to start: exited normally.\n (session not created: Devtools port number file contents \u003C> were in an unexpected format)\n (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)","stacktrace":"#0 0x5575131666aa \u003Cunknown>\n#1 0x557512e490dc \u003Cunknown>\n#2 0x557512e7e02a \u003Cunknown>\n#3 0x557512e7a43b \u003Cunknown>\n#4 0x557512ec4ef9 \u003Cunknown>\n#5 0x557512eb8613 \u003Cunknown>\n#6 0x557512e884f7 \u003Cunknown>\n#7 0x557512e88e4e \u003Cunknown>\n#8 0x55751312c87b \u003Cunknown>\n#9 0x557513130921 \u003Cunknown>\n#10 0x55751311836e \u003Cunknown>\n#11 0x557513131482 \u003Cunknown>\n#12 0x5575130fcccf \u003Cunknown>\n#13 0x5575131560a8 \u003Cunknown>\n#14 0x557513156280 \u003Cunknown>\n#15 0x5575131657dc \u003Cunknown>\n#16 0x7f893c2f71ca start_thread\n"}} | headers=HTTPHeaderDict({'Content-Length': '956', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'}) 2024-07-11 22:39:06,383 - DEBUG - Finished Request 2024-07-11 22:39:06,386 - DEBUG - error initializing the driver details are Message: session not created: Chrome failed to start: exited normally. (session not created: Devtools port number file contents <> were in an unexpected format) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Stacktrace:

0 0x5575131666aa

1 0x557512e490dc

2 0x557512e7e02a

3 0x557512e7a43b

4 0x557512ec4ef9

5 0x557512eb8613

6 0x557512e884f7

7 0x557512e88e4e

8 0x55751312c87b

9 0x557513130921

10 0x55751311836e

11 0x557513131482

12 0x5575130fcccf

13 0x5575131560a8

14 0x557513156280

15 0x5575131657dc

16 0x7f893c2f71ca start_thread

2024-07-11 22:42:59,215 - DEBUG - Selenium Manager binary found at: /home/sftpuser/vevn/lib64/python3.9/site-packages/selenium/webdriver/common/linux/selenium-manager 2024-07-11 22:42:59,215 - DEBUG - Executing process: /home/sftpuser/vevn/lib64/python3.9/site-packages/selenium/webdriver/common/linux/selenium-manager --browser chrome --debug --language-binding python --output json 2024-07-11 22:43:02,618 - DEBUG - Found chromedriver 126.0.6478.55 in PATH: /usr/local/bin/chromedriver 2024-07-11 22:43:02,618 - DEBUG - chrome detected at /usr/bin/google-chrome 2024-07-11 22:43:02,619 - DEBUG - Running command: /usr/bin/google-chrome --version 2024-07-11 22:43:02,619 - DEBUG - Output: "Google Chrome 126.0.6478.126 " 2024-07-11 22:43:02,619 - DEBUG - Detected browser: chrome 126.0.6478.126 2024-07-11 22:43:02,619 - DEBUG - Required driver: chromedriver 126.0.6478.126 2024-07-11 22:43:02,619 - DEBUG - Driver path: /usr/local/bin/chromedriver 2024-07-11 22:43:02,619 - DEBUG - Browser path: /usr/bin/google-chrome 2024-07-11 22:43:02,621 - DEBUG - Started executable: /usr/local/bin/chromedriver in a child process with pid: 1064780 using 0 to output -3 2024-07-11 22:43:02,807 - DEBUG - POST http://localhost:50889/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'chrome', 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'browserVersion': None, 'goog:chromeOptions': {'excludeSwitches': ['enable-automation'], 'useAutomationExtension': False, 'prefs': {'download.default_directory': '/home/sftpuser/tools/Efillings/DATA/GUIPS4704M', 'download.prompt_for_download': False, 'download.directory_upgrade': True, 'safebrowsing.enabled': True}, 'extensions': [], 'binary': '/usr/bin/google-chrome', 'args': ['user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', '--no-sandbox', '--disable-dev-shm-usage', '--disable-setuid-sandbox', '--disable-gpu', '--disable-blink-features=AutomationControlled', '--start-maximized', '--headless=new']}}}} 2024-07-11 22:43:02,808 - DEBUG - Starting new HTTP connection (1): localhost:50889 2024-07-11 22:43:09,963 - DEBUG - http://localhost:50889 "POST /session HTTP/11" 500 0 2024-07-11 22:43:09,963 - DEBUG - Remote response: status=500 | data={"value":{"error":"disconnected","message":"disconnected: Unable to receive message from renderer\n (failed to check if window was closed: disconnected: not connected to DevTools)\n (Session info: chrome=126.0.6478.126)","stacktrace":"#0 0x55a86b2e06aa \u003Cunknown>\n#1 0x55a86afc30dc \u003Cunknown>\n#2 0x55a86afaa456 \u003Cunknown>\n#3 0x55a86afa7f76 \u003Cunknown>\n#4 0x55a86afa85ef \u003Cunknown>\n#5 0x55a86afc3cb4 \u003Cunknown>\n#6 0x55a86af97ac3 \u003Cunknown>\n#7 0x55a86af9734f \u003Cunknown>\n#8 0x55a86b03f10d \u003Cunknown>\n#9 0x55a86b032613 \u003Cunknown>\n#10 0x55a86b0024f7 \u003Cunknown>\n#11 0x55a86b002e4e \u003Cunknown>\n#12 0x55a86b2a687b \u003Cunknown>\n#13 0x55a86b2aa921 \u003Cunknown>\n#14 0x55a86b29236e \u003Cunknown>\n#15 0x55a86b2ab482 \u003Cunknown>\n#16 0x55a86b276ccf \u003Cunknown>\n#17 0x55a86b2d00a8 \u003Cunknown>\n#18 0x55a86b2d0280 \u003Cunknown>\n#19 0x55a86b2df7dc \u003Cunknown>\n#20 0x7f455cc141ca start_thread\n"}} | headers=HTTPHeaderDict({'Content-Length': '963', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'}) 2024-07-11 22:43:09,963 - DEBUG - Finished Request 2024-07-11 22:43:09,966 - DEBUG - error initializing the driver details are Message: disconnected: Unable to receive message from renderer (failed to check if window was closed: disconnected: not connected to DevTools) (Session info: chrome=126.0.6478.126) Stacktrace:

0 0x55a86b2e06aa

1 0x55a86afc30dc

2 0x55a86afaa456

3 0x55a86afa7f76

4 0x55a86afa85ef

5 0x55a86afc3cb4

6 0x55a86af97ac3

7 0x55a86af9734f

8 0x55a86b03f10d

9 0x55a86b032613

10 0x55a86b0024f7

11 0x55a86b002e4e

12 0x55a86b2a687b

13 0x55a86b2aa921

14 0x55a86b29236e

15 0x55a86b2ab482

16 0x55a86b276ccf

17 0x55a86b2d00a8

18 0x55a86b2d0280

19 0x55a86b2df7dc

20 0x7f455cc141ca start_thread

victorhazbun commented 1 month ago

Same here:

Failure/Error: Unable to infer file and line number from backtrace

          Selenium::WebDriver::Error::WebDriverError:
            disconnected: not connected to DevTools
              (failed to check if window was closed: disconnected: not connected to DevTools)
              (Session info: chrome=127.0.6533.72)
          # 0   chromedriver                        0x000000010df380e8 chromedriver + 5169384
          # 1   chromedriver                        0x000000010df2ffba chromedriver + 5136314
          # 2   chromedriver                        0x000000010daac36c chromedriver + 402284
          # 3   chromedriver                        0x000000010da91d26 chromedriver + 294182
          # 4   chromedriver                        0x000000010da91c13 chromedriver + 293907
          # 5   chromedriver                        0x000000010daae782 chromedriver + 411522
          # 6   chromedriver                        0x000000010db3b92b chromedriver + 989483
          # 7   chromedriver                        0x000000010db1c853 chromedriver + 862291
          # 8   chromedriver                        0x000000010daec5c6 chromedriver + 665030
          # 9   chromedriver                        0x000000010daece4e chromedriver + 667214
          # 10  chromedriver                        0x000000010defad00 chromedriver + 4918528
          # 11  chromedriver                        0x000000010deffcfd chromedriver + 4939005
          # 12  chromedriver                        0x000000010df003d5 chromedriver + 4940757
          # 13  chromedriver                        0x000000010dedbde4 chromedriver + 4791780
          # 14  chromedriver                        0x000000010df006c9 chromedriver + 4941513
          # 15  chromedriver                        0x000000010decd5b4 chromedriver + 4732340
          # 16  chromedriver                        0x000000010df20898 chromedriver + 5073048
          # 17  chromedriver                        0x000000010df20a57 chromedriver + 5073495
          # 18  chromedriver                        0x000000010df2fb6e chromedriver + 5135214
          # 19  libsystem_pthread.dylib             0x00007ff818a8318b _pthread_start + 99
          # 20  libsystem_pthread.dylib             0x00007ff818a7eae3 thread_start + 15
mpkhr commented 1 month ago

Same problem, selenium_chrome stopped working from one day to another without any known change (no library updates, no OS updates).

Stack traces vary a bit, but look similar. Here are two examples:

1.1) Failure/Error: Unable to infer file and line number from backtrace

          Selenium::WebDriver::Error::NoSuchWindowError:
            no such window
              (Session info: chrome=127.0.6533.74)
          # 0   chromedriver                        0x0000000105119088 cxxbridge1$str$ptr + 1887276
          # 1   chromedriver                        0x0000000105111764 cxxbridge1$str$ptr + 1856264
          # 2   chromedriver                        0x0000000104d20694 cxxbridge1$string$len + 88116
          # 3   chromedriver                        0x0000000104d90100 cxxbridge1$string$len + 545440
          # 4   chromedriver                        0x0000000104d59474 cxxbridge1$string$len + 321044
          # 5   chromedriver                        0x0000000104d5a0e4 cxxbridge1$string$len + 324228
          # 6   chromedriver                        0x00000001050e0a6c cxxbridge1$str$ptr + 1656336
          # 7   chromedriver                        0x00000001050e54c8 cxxbridge1$str$ptr + 1675372
          # 8   chromedriver                        0x00000001050c6950 cxxbridge1$str$ptr + 1549556
          # 9   chromedriver                        0x00000001050e5c78 cxxbridge1$str$ptr + 1677340
          # 10  chromedriver                        0x00000001050b8660 cxxbridge1$str$ptr + 1491460
          # 11  chromedriver                        0x0000000105102ac0 cxxbridge1$str$ptr + 1795684
          # 12  chromedriver                        0x0000000105102c3c cxxbridge1$str$ptr + 1796064
          # 13  chromedriver                        0x0000000105111398 cxxbridge1$str$ptr + 1855292
          # 14  libsystem_pthread.dylib             0x000000019ad02f94 _pthread_start + 136
          # 15  libsystem_pthread.dylib             0x000000019acfdd34 thread_start + 8

     1.2) Failure/Error: Unable to infer file and line number from backtrace

          Selenium::WebDriver::Error::InvalidArgumentError:
            invalid argument: 'handle' must be a string
              (Session info: chrome=127.0.6533.74)
          # 0   chromedriver                        0x0000000105119088 cxxbridge1$str$ptr + 1887276
          # 1   chromedriver                        0x0000000105111764 cxxbridge1$str$ptr + 1856264
          # 2   chromedriver                        0x0000000104d2082c cxxbridge1$string$len + 88524
          # 3   chromedriver                        0x0000000104d8fd18 cxxbridge1$string$len + 544440
          # 4   chromedriver                        0x0000000104d59474 cxxbridge1$string$len + 321044
          # 5   chromedriver                        0x0000000104d5a0e4 cxxbridge1$string$len + 324228
          # 6   chromedriver                        0x00000001050e0a6c cxxbridge1$str$ptr + 1656336
          # 7   chromedriver                        0x00000001050e54c8 cxxbridge1$str$ptr + 1675372
          # 8   chromedriver                        0x00000001050c6950 cxxbridge1$str$ptr + 1549556
          # 9   chromedriver                        0x00000001050e5c78 cxxbridge1$str$ptr + 1677340
          # 10  chromedriver                        0x00000001050b8660 cxxbridge1$str$ptr + 1491460
          # 11  chromedriver                        0x0000000105102ac0 cxxbridge1$str$ptr + 1795684
          # 12  chromedriver                        0x0000000105102c3c cxxbridge1$str$ptr + 1796064
          # 13  chromedriver                        0x0000000105111398 cxxbridge1$str$ptr + 1855292
          # 14  libsystem_pthread.dylib             0x000000019ad02f94 _pthread_start + 136
          # 15  libsystem_pthread.dylib             0x000000019acfdd34 thread_start + 8
diemol commented 1 month ago

There is little we can do about this issue at the Selenium project because it is entirely related to the Chrome browser, which cannot start correctly in some situations. Please report this to the Chrome folks and provide them with a way to reproduce the issue.

github-actions[bot] commented 1 month ago

Hi, @pirquessa. This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team. Feel free to comment the issues that you raise back in this issue. Thank you.

mpkhr commented 1 month ago

Okay, I found the solution. If you launch it in headful you can see it's asking the user to select the default search engine, blocking the test from executing. This behaviour can be disabled with the option --disable-search-engine-choice-screen

Here's a full config that works for me:

Capybara.register_driver :selenium_chrome_headless_tmp_fix do |app|
  options = Selenium::WebDriver::Chrome::Options.new
  options.add_argument('--headless')
  options.add_argument('--window-size=1280,800')
  options.add_argument('--disable-search-engine-choice-screen')

  Capybara::Selenium::Driver.new(
    app,
    browser: :chrome,
    options: options
  )
end

I'd suggest to make this the default in the selenium_chrome_headless driver

pirquessa commented 1 month ago

Thx for the tip @mpkhr. But this fix has already been applied in my company without any change on my situation :'(

github-actions[bot] commented 5 days ago

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