0

Try to block/cross the popup, see the image:enter image description here

My Code:

driver = webdriver.Chrome()
driver.get('https://www.facebook.com/')
#More codes between (useless for this question)
alertObj = driver.switch_to.alert
alertObj.dismiss

Gave me the error:

selenium.common.exceptions.NoAlertPresentException: Message: no such alert

Full Message:

Traceback (most recent call last): File "D:\python_projects\facebook\page\index.py", line 25, in < module> alertObj = driver.switch_to.alert File "C:\Python\lib\site-packages\selenium\webdriver\remote\switch_to.py", lin e 55, in alert alert.text File "C:\Python\lib\site-packages\selenium\webdriver\common\alert.py", line 69 , in text return self.driver.execute(Command.GET_ALERT_TEXT)["value"] File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", lin e 320, in execute self.error_handler.check_response(response) File "C:\Python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoAlertPresentException: Message: no such alert

Andersson
  • 51,635
  • 17
  • 77
  • 129
  • @Andersson I am not able to match my question with the link you povided.... – jumping in ocean Sep 02 '18 at 11:21
  • What do you mean by *"match my answer"*? What is your *answer*? – Andersson Sep 02 '18 at 11:22
  • Sorry, I mean "match my question", meanwhile I got an alternative answer for this at https://stackoverflow.com/a/34371491/10303845 but what if I want to handle all the alerts?? – jumping in ocean Sep 02 '18 at 11:27
  • This is not an alert. Alert is popup created by calling JavaScript `alert()` function. Alert contains one button only. This popup is Chrome notification and it should be handled differently... – Andersson Sep 02 '18 at 11:34

0 Answers0