Pop up are mainly Javascript alerts.
We need to identify as an first step whether its a Java script alert or a new window.
Usually as an thumb rule,
1.Javascript Alert didn't not have any url.
2. It may have a message Text
3. Have only two buttons :: Accept (Ok) and dismiss(Cancel).
4. Firepath will not able to identify these OK and cancel Button.
First switch the control to JS alert then either accept or dismiss the alert according to your
requirement.
steps::
WebDriver driver = new FirefoxDriver();
Alert alt = driver.switchTo().alert(); //this will switch the control to alert pop-up
alt.accept(); // to click on OK or to accept the alert pop-up
//alt.dismiss(); // to click on CANCEL
We need to identify as an first step whether its a Java script alert or a new window.
Usually as an thumb rule,
1.Javascript Alert didn't not have any url.
2. It may have a message Text
3. Have only two buttons :: Accept (Ok) and dismiss(Cancel).
4. Firepath will not able to identify these OK and cancel Button.
First switch the control to JS alert then either accept or dismiss the alert according to your
requirement.
steps::
WebDriver driver = new FirefoxDriver();
Alert alt = driver.switchTo().alert(); //this will switch the control to alert pop-up
alt.accept(); // to click on OK or to accept the alert pop-up
//alt.dismiss(); // to click on CANCEL
No comments:
Post a Comment