The application i am working throws a lot of unexpected alerts . I wanted to implement a way that catch all these through a common method isAlert present .
But how to call isAlertpresnt for each step in webdrriver , can anyone help me here ?
Typically my method would be like this :-
public void checkAlert() {
try {
WebDriverWait wait = new WebDriverWait(driver, 2);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.accept();
} catch (Exception e) {
//exception handling
}
}
The issue is how to call it before every step ? I know this will make my code slow but badly want this to be implemented .
I am looking for something which executes after each command\step in my test .Is this possible ?
Currently i am calling this method in all expected scenarios with a try catch.
junit
ortestng
to run the tests? You may look at availableannotations
. – Hulton