Tuesday, February 26, 2013

How to close the alert/Popup window in webdriver


//Click a link which will open the alert (like, open a File open/save window)

driver.findElement(By.linkText("amazon_referrals_2009.xlsx")).click();

//Now it will open a File open/save window

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

//Now the newly opened window will be closed

No comments:

Post a Comment