SeleniumHQ / selenium

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

[🐛 Bug]: Inconsistent shutdown behavior between drivers #11303

Open jeetjddas opened 1 year ago

jeetjddas commented 1 year ago

What happened?

I was trying to use the new feature Selenium Manager using Edge browser Unfortunately, after every successful run of the program, the browser gets automatically closed

Language: Python Editor: Pycharm

Note: Firefox browser is working fine till now.

How can we reproduce the issue?

from selenium import webdriver

driver = webdriver.Edge()
driver.get("https://www.google.com/")

Relevant log output

It ran successfully, so there is no log to show from the console.

Operating System

Windows 10 pro

Selenium version

Selenium 4.6.0

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

Microsoft Edge 107.0.1418.56

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

No driver has been used

Are you using Selenium Grid?

No

github-actions[bot] commented 1 year ago

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

titusfortner commented 1 year ago

The browser is supposed to close when the program finishes running. You can keep it open on Chrome & Edge drivers by passing in an Options instance and setting detach = True

jeetjddas commented 1 year ago

But if I use Firefox, without using Options instance, the browser remains open. Only in case of Chrome and Edge, the browser is getting closed automatically if I am not using Options instance and setting detach = True. Is it a valid deviation? @titusfortner

titusfortner commented 1 year ago

Nope, that's a bug. I can duplicate it. Thanks for reporting.

titusfortner commented 1 year ago

Did a run through of existing behaviors of different languages:

Ideally the behavior is the same between languages and browsers, let's discuss at next TLC meeting.

diemol commented 1 year ago

Was this discussed?

titusfortner commented 1 year ago

A little in the channel. It was added right after the last tlc meeting.

titusfortner commented 1 year ago

It was discussed at TLC Meeting - https://www.selenium.dev/meetings/2022/tlc-12-08/#proposalsdecisions

It was agreed that ending the processes for everything on program exit would be ideal, but that because of backwards compatibility issues we would need bandwidth to do the work and field questions from irate users, which is not currently a priority.

The easiest way to deal with irate users would be to point out the alternative for maintaining current behavior (browsers stay open when program exits. Chrome/Edge support this with the detach option, but Mozilla does not. So this issue is essentially pending: https://github.com/mozilla/geckodriver/issues/595

titusfortner commented 9 months ago

Mozilla is not prioritizing that feature. I think this might be worth doing regardless.

At the very least we should be killing the driver process, even if that doesn't/won't kill the browser process.

github-actions[bot] commented 9 months ago

This issue is looking for contributors.

Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.

github-actions[bot] commented 16 hours ago

This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days.