Selenium WebDriver how to close browser popup

前端 未结 9 1099
悲&欢浪女
悲&欢浪女 2020-11-27 18:29

I am writing tests for a web App using selenium webDriver and came across a scenario where when I try to close the browser I get a popup saying \"Are you sure? The page is a

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 18:52

    You can interact with alerts and the like using the Alert API. Switching to the alert and confirm it would look like this (in Java):

    Alert alert = driver.switchTo().alert();
    alert.accept();
    

    This is also explained in the Selenium FAQ.

提交回复
热议问题