How to handle Alert in Selenium

Handle alerts

driver.switchTo().Alert();

alert.accept()// clicked on ok

alert.dismiss(); //clicked on cancel

for example:

public void alert(){
  String str=driver.switchTo().alert().getText();
  System.out.println(str);
  driver.switchTo().alert().accept();
  //driver.switchTo().alert().dismiss();

 }

1 comment:

  1. Really nice topics you had discussed above. I am much impressed. Thank you for providing this nice information here.

    Software Testing Company

    QA Services

    Game Testing Services

    Video Game Testing Companies

    ReplyDelete