Tuesday, 11 September 2012

Selenium WebDriver – Handling JavaScript Popups

Selenium WebDriver – Handling JavaScript Popups

public class HandlingPopup  {

static WebDriver driver = new FirefoxDriver();

 public static void Handle(){

//switching focus to alert box
Alert alert =driver.switchTo().alert();

//Get text from the alert box
 System.out.println(alert.getText());

//click on Ok

 alert.accept();

//cancel the popup

driver.quit();

public static void main(String args[]){

 Handle();

 }
}

No comments:

Post a Comment