I want to write a Python script using Selenium and Chrome where Selenium won't close the Chrome browser when the script finishes. From doing a bunch of googling, it looks like the standard solution is to use the detach option. But when I run the following script:
import seleniumfrom selenium import webdriverfrom selenium.webdriver.chrome.options import Optionschrome_options = Options() chrome_options.add_experimental_option("detach", True)driver = webdriver.Chrome(options=chrome_options)driver.get("https://www.google.com/")It opens up Chrome, goes to Google's homepage, and then closes the browser. It's not throwing any errors.
Any idea why it's not working? I'm using the latest version of Google Chrome on Windows 10, and I've got the latest version of the selenium module installed. I couldn't find anything online that said the experimental detach option no longer existed. And I double checked the API, and it looks like it's the right syntax.