Reputation: 109
I was using Chrome driver version 74 before and chrome browser version 74. There were no issues with alerts during that time. When my browser got auto updated to version 76, I did replace Chrome driver version to 76.
When i ran the same scripts after updating, alerts on my browser started auto dismissing when it runs below code (code snippet of wait.py in selenium ). I did retest the same code on different PC with driver 74 and browser 74 and it worked fine.
I suspected chrome changed alert behavior in latest drivers and tried to use following statement in chrome driver options but did not work. "profile.managed_default_content_settings.popups":0,
Popup is getting dismissed at line "value = method(self._driver)" of the below code.
def until(self, method, message=''):
"""Calls the method provided with the driver as an argument until the \
return value is not False."""
screen = None
stacktrace = None
end_time = time.time() + self._timeout
while True:
try:
value = method(self._driver)
if value:
return value
except self._ignored_exceptions as exc:
screen = getattr(exc, 'screen', None)
stacktrace = getattr(exc, 'stacktrace', None)
time.sleep(self._poll)
if time.time() > end_time:
break
raise TimeoutException(message, screen, stacktrace)
chromeoptions used:
self._chromeoptions = Options
self._chromeops = webdriver.ChromeOptions()
prefs = {"download.default_directory": mainpath + r"\bin\download_files",
"profile.default_content_setting_values.geolocation": 1,
"download.prompt_for_download": False,
'credentials_enable_service': False,
'profile': {
'password_manager_enabled': False
},
"applicationCacheEnabled": True,
"safebrowsing": {"enabled": True, "malware": {"enabled": True}}}
self._caps = DesiredCapabilities.CHROME
self._chromeops.add_experimental_option("prefs", prefs)
self._caps.setdefault("pageLoadStrategy", "normal")
self._chromeops.add_experimental_option("excludeSwitches", ["ignore-certificate-errors", "enable-automation"])
self._chromeops.add_argument("--start-maximized")
self._chromeops.add_argument("--disable-plugins")
self._chromeops.add_argument("--disable-extensions")
self._chromeops.set_capability('unexpectedAlertBehaviour', "ignore")
self._chromeops.add_experimental_option("useAutomationExtension", False)
Additional details:
Method calling function until...
def wait_till_inactive_delay(self, xpath, delay=20):
xpath = self.generate_xpath_structure(xpath)
WebDriverWait(self.driver, delay, ignored_exceptions= [NoSuchElementException]).until(expected_conditions.invisibility_of_element_located((By.XPATH, xpath)))
With old chromedriver, when there is alert and above fucntion is invoked it would ignore and proceed but now when there is alert open in browser and above method is called then alert is getting dismissed.
I am expecting chrome browser / driver to allow user to accept popup using switch_to_alert.accpet() instead of it dismissing the popups.
Upvotes: 2
Views: 947
Reputation: 109
('unhandledPromptBehavior', "ignore")
Above desired capability ignored the popups
Upvotes: 3