-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛 Bug]: Selenium client does not terminate after Quit() and Dispose(), causing subsequent clients to fail due to a timeout #13595
Comments
@zaneclaes, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
Everybody here executes a lot of tests, even in parallel. @zaneclaes when you say:
can you provide exact code which fails? |
I am aware of that. Nonetheless, in the virtualized machine conditions in this ticket, the bug appears, as is demonstrated by the many comments. Perhaps I should have stated that the problem is Linux-Docker specific in the subject? The bug does not appear at all any of our non-virtualized Mac and Windows machines.
Sorry, I thought the multiple examples I cited in the linked Stack Overflow thread would be enough. Here's my own:
Then just call But perhaps the more relevant bit is that the code must be running in a Docker container, i.e.,
|
Well... this is strange. I was trying to create a minimal repro (since I'm headed on PTO this weekend), and the exact same code running on the same physical Docker host does not trigger the issue. I can only conclude there are some confounding factors, i.e., something else in the application is somehow interfering with Selenium's ability to gracefully shut down. I guess I'm not as confident any more that this is actually a Selenium bug, though I'm not sure how to go about diagnosing the root cause when in our app. Nonetheless, it feels appropriate to close this issue... |
|
Lol, I couldn't reproduce the issue on WSL, works smoothly. In any case come back to us with reproducible sample. |
While that is true of the OP, it is not true of many of the responses/answers, where there are 25+ upvotes for both Firefox and Chrome requiring a timeout to work successfully.
I'm frustrated by this too, but it's unsurprising considering the error message is so broad and uninformative that it is effectively useless.
This is an anti-pattern. Per the Microsoft definition of the Dispose pattern, implementing
Yet, waiting after a Quit before starting a second session always fixes the problem. If the issue is unrelated to multiple sessions as you seem to be suggesting... how can we possibly explain the fix?
Good to know!
Nobody ever said the issue appeared on WSL, and in fact I explicitly stated (several times now, including in the OP) it only occurred in a docker environment... so I'm not sure what you're laughing at. |
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. |
What happened?
Please refer to this StackOverflow issue. Specifically, consider that variations of this solution have worked for many of the 100+ reporters of the bug:
So somewhere I read that after disposing the driver I should wait a few seconds before starting the next test, so I added the following line to dispose method:
With this sleep modification I have no longer get the timeout error and there is no unnecessarily opened chromedriver.exe and chrome.exe processses.
How can we reproduce the issue?
Try to run Selenium in a Linux-based Docker container. Use any working Selenium code, but after Quit/Dispose, immediately run the code again. The fact that the Selenium code has not exited means that subsequent attempts to create a new driver exhibit the error. Adding the
Thread.Sleep
fixes the issue, but it is impossible to guess the correct amount of time to sleep. Most of the time 3 seconds is sufficient, but sometimes 30 seconds is insufficient — it depends on when precisely the client actually exits, so the only way it appears an end-user can concretely fix this issue is to implement some kind of process inspector which waits for Selenium to finish its job and the process to ACTUALLY exit.Relevant log output
Operating System
Linux (Ubuntu) + Docker
Selenium version
4.17.0
What are the browser(s) and version(s) where you see this issue?
Chromium (all versions)
What are the browser driver(s) and version(s) where you see this issue?
Chromium (all versions)
Are you using Selenium Grid?
No response
The text was updated successfully, but these errors were encountered: