Answers

Question and Answer:

  Home  Automation

⟩ Explain me how to Handle Alerts in Selenium WebDriver?

Here are a few methods of Alerts handling which are widely used in Selenium Webdriver.

☛ void dismiss() is used to click on the 'Cancel' button of the alert.

☛ driver.switchTo().alert().dismiss();

☛ void accept() is used to click on the 'OK' button of the alert.

☛ driver.switchTo().alert().accept();

☛ String getText() is used to capture the alert message.

☛ driver.switchTo().alert().getText();

☛ void sendKeys(String stringToSend) is used to send some data to alert box.

☛ driver.switchTo().alert().sendKeys("Text");

 143 views

More Questions for you: