When browser redirect me to telegram page, i have an alert(look at the screenshot). How can I cancel It?
I use this code, but i have an error at the second line:
alert = Alert(driver)
alert.dismiss()
Screenshot of alert, which i try to close:
CodePudding user response:
Please try this
driver.switch_to.alert.accept()
This should work
CodePudding user response:
You need to switch the focus to the alert box before accessing it.
Try this
WebDriverWait(driver, 10).until(EC.alert_is_present())
alert_box = driver.switch_to.alert
alert_box.dismiss()
CodePudding user response:
Can you try this:
driver.switch_to.alert.dismiss()