Reputation: 53
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()
Upvotes: 4
Views: 3606
Reputation: 165
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
Upvotes: 5