Thursday 18 July 2013

Selenium WebDriver : How to Handle JavaScript Alerts and Prompts

Selenium 2 provides Alerts API, to work on pop & alert window –
// Get a handle to the open alert, prompt or confirmation
Alert alert = driver.switchTo().alert();
// Get the text of the alert or prompt
alert.getText();
// And acknowledge the alert (equivalent to clicking “OK”)

No comments:

Post a Comment