如何接受硒(Python)中的警报?

时间:2018-11-13 06:09:10

标签: python selenium selenium-chromedriver alert

我必须使用python(selenium)在网站上接受警报,

为此,我尝试了:

     from selenium import webdriver   
     driver = webdriver.Chrome() 
     driver.get('http://mysite/which/shows/alert')  
     alert = driver.switch_to_alert()

但显示为

  raise exception_class(message, screen, stacktrace)
  selenium.common.exceptions.NoAlertPresentException: 
  Message: no such alert
  (Session info: chrome=70.0.3538.102)
  (Driver info: chromedriver=2.43.600210 

我也尝试过

 alertobj=driver.switch_to.alert

但存在相同的错误

谢谢

0 个答案:

没有答案