from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
safari_option = Options()
safari_option.add_experimental_option("detach", True)
# Prevent closing browser after done execution
driver = webdriver.Safari(options=safari_option)
driver.get("https://www.google.com/?client=safari")
elem = driver.find_element(By.NAME, "q")
elem.clear()
elem.send_keys("test")
I want to prevent safari from closing after the webdriver has finished so that I can see the process of automating another website clearly one by one.
I tried using the safari_option.add_experimental_option("detach", True)
as has been done here
Python selenium keep browser open
for chrome. But I'm not quite sure why it did not work for Safari instead.Seems like a simple problem but couldn't find an answer for it on google or maybe Im blind. Im pretty new to Selenium btw.
Thanks