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;
options = ChromeOptions()
options.headless = True
options.set_capability("UNEXPECTED_ALERT_BEHAVIOUR", "ACCEPT")
options.set_capability("unexpectedAlertBehaviour", "accept")
options.set_capability("CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR", "ACCEPT")
options.set_capability("UnexpectedAlertBehaviour", "ACCEPT")
webdriver.DesiredCapabilities.CHROME["unexpectedAlertBehaviour"] = "accept"
cls.driver = webdriver.Chrome(chrome_options=options)
However, I am still randomly experiencing this unexpectedalertpresent exception:
selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: Message: unexpected alert open: {Alert text : }
When I run the browser in non headless mode (head mode?) I see no such alerts, but the test still randomly fails with this exception, despite my efforts to set this elusive option.