selenium: [šŸ› Bug]: Chrome sessions not being closed properly

What happened?

I’m using Selenium and Pytest under Windows 11 to run a sequence of testcases, usually in headless mode. Each testcase starts a browser session, does its thing and then ends the session using quit(). Then the next one starts a fresh session in the same way and so on.

The last time this has been verified as working was on 29/4/2024, using Selenium 4.19 and chromedriver 123.0.6312.122 and Chrome version 123.0.6312.106.

Since then, the Chrome version has been updated to 124.0.6367.208.

I’ve been trying Selenium 4.19 and 4.21 (which downloaded chromedriver 124.0.6367.207) but with both the issue remains.

ISSUE: When running this test sequence, browser sessions don’t get closed properly and remain in Windows task manager. The next session gets started and they stack up to the point where the CPU is constantly at 100% load and becomes unresponsive. While running, a browser instance usually generate 2-5% CPU load but when they idle after having been quit (or not quite), they take up about 8-10% CPU each and once there’S about 10 of them, CPU goes brrr.

What I also noticed is that since this issue exists, I get an info displayed in the console that I hadn’t seen before: ā€œCreated TensorFlow Lite XNNPACK delegate for CPU.ā€ No idea if this is related to the issue tho, just an observation.

I found these other users who’ve reported similar issues, but as there was no feedback or progress, I thought I’d open a ticket: https://groups.google.com/g/selenium-users/c/M9BJY5Ow_zQ

There is also this issue, which might be related? https://github.com/SeleniumHQ/selenium/issues/13850 OP description sounded a bit different, but commenter (https://github.com/SeleniumHQ/selenium/issues/13850#issuecomment-2096541878) sounded same(ish).

I’m available if you need any more info, sorry if this is considered a dub.

How can we reproduce the issue?

can't share

Relevant log output

let me know if needed

Operating System

Windows 11

Selenium version

Python 4.19 and 4.21

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

Chrome 124.0.6367.208

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

chromedriver 123.0.6312.122 and 124.0.6367.207

Are you using Selenium Grid?

nope

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

@Harrier-Du-Bois - remove all chrome options arguments that you apply and the issue will resolve itself. There seems to be an issue/bug with passing the ā€œā€“no sandboxā€ argument…I’ve raised it with the chrome team but as i was able to resolve it by removing the arguments I’m not sure if they’re going to fix the main issue.

Hi @DeLaphante and thank you for your helpful reply. I had indeed always been using the --nosandbox argument and removing it did fix the issue, so thank you again for sharing your findings.

@Harrier-Du-Bois - remove all chrome options arguments that you apply and the issue will resolve itself. There seems to be an issue/bug with passing the ā€œā€“no sandboxā€ argument…I’ve raised it with the chrome team but as i was able to resolve it by removing the arguments I’m not sure if they’re going to fix the main issue.

Yes, the driver should be killing that process when it receives the driver.quit and if that isn’t happening for some reason, we need to investigate why. Thanks.

Usually this happens when something prevents the driver.quit command from executing. Turn on logging to ensure that the command is getting sent properly.

I upgraded my platform to the next version 126 ( chromeDirver, and chrome Borwser) And all the pbs are fixed. thank you

Hello, I had the same pb when upgrading the chromeDriver from 122 to 125 to fit the version to my installed chrome version. I tried to upgrade too to the latest version 4.21.0 of SeleniumServer, but with no change. Once we launch one test chrome over consume the CPU. Once the test is fichiched and browser is closed, the process continue to work and consuming CPU and Memory.

It’s not a solution but once I did that, it fixed the pb : I just try to kill process with cmd : taskkill /F /IM chrome.exe /T And from this moment all is back to normal. So I think that it was an access pb or some think else that I can’t understand right now. I update if I have more information.