How To Set UnexpectedAlertBehaviour In Selenium Python
This question deals with setting the UnexpectedAlertBehaviour of a Selenium webdriver in Java. How do you do the same thing in Python's ChromeDriver? I have tried the following;
Solution 1:
As chromedriver becoming W3C compliant . We need use unhandledPromptBehavior Checked on ChromeDriver 76.0.3809.126 (Runs in W3C standard compliant mode by default)
chrome_options = Options()
chrome_options.set_capability('unhandledPromptBehavior', 'accept')
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.google.com")
driver.execute_script('alert(\"HI\");')
time.sleep(10)
print(driver.title)
time.sleep(10)
Reference Chromedriver: Issue 2597: Support new unhandledPromptBehavior modes
Post a Comment for "How To Set UnexpectedAlertBehaviour In Selenium Python"