My Blog List

Monday, November 14, 2011

Selenium - Handle JavaScript Alert and Confirmation boxes


Confirmation boxes  and Alerts are handled in same way in selenium.

  1. var alert = driver.switchTo().alert();
  2. alert.dismiss();  //Click Cancel or Close window operation
  3. alert.accept();   //Click ok

Handle Confirmation boxes via JavaScript,
driver.executeScript("window.confirm = function(msg){return true;};");


2 comments:

  1. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete