So I was working on something that requires me to keep the browser open until unless it is closed by the user, however, the browser automatically closes after finishing its tasks, is there any way to prevent this?
def main():
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://www.google.com/")
main()
If you want it to stay open, you have to use the 'detach' option
from selenium.webdriver.chrome.options import Options
def main():
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.maximize_window()
driver.get("https://www.google.com/")
This should do it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With