How to handle JavaScript alerts, confirmation and prompts, in selenium
/ Get a handle to the open alert, prompt or confirmation
Alert alert = driver.switchTo().alert();
Alert alert = driver.switchTo().alert();
Alert
is an interface. There below are the methods that are used
//Will
Click on OK button.
alert.accept();
alert.accept();
//
Will click on Cancel button.
alert.dismiss()
alert.dismiss()
//will
get the text which is present on th Alert.
alert.getText();
alert.getText();
//Will
pass the text to the prompt popup
alert.sendkeys();
alert.sendkeys();
//Is
used to Authenticate by passing the credentials
alert.authenticateUsing(Credentials credentials)
alert.authenticateUsing(Credentials credentials)
Comments
Post a Comment