I have this problem with selenium webdriver tests with chromedriver. Although I can run tests successfully using the Chrome browser, I cannot run the same tests in headless mode.
I cannot handle Js warnings. In fact, when taking a picture, it seems that the warning will not even appear.
Warning screenshot
I tried several workarounds:
1) driver.window_handles No other window seems to be present
2) driver.execute_script("window.confirm = function(){return true;}") → Nothing has changed with this script
3) element = WebDriverWait(driver, 20).until(EC.alert_is_present()) and, of course, an explicit wait
In browser mode, I use plain:
try: print driver.switch_to.alert.text driver.switch_to.alert.accept() except NoAlertPresentException as e: print("no alert")
Does anyone else have this problem with headless alerts?
- chromedriver v.2.30.477691
- Chrome Version 59.0.3071.115
selenium-webdriver selenium-chromedriver google-chrome-headless
Alex pas
source share