Selenium WebDriver how to close browser popup

前端 未结 9 1097
悲&欢浪女
悲&欢浪女 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:49

    IAlert alert = driver.SwitchTo().Alert();
    
    alert.Accept(); //for two buttons, choose the affirmative one
    // or
    alert.Dismiss(); //to cancel the affirmative decision, i.e., pop up will be dismissed and no action will take place
    

提交回复
热议问题