|
Post by leiwang on Feb 19, 2016 3:52:39 GMT
With IE, if we call SeleniumPlus.Click(Map.WindowMain.ButtonToOpenAlert, "20, 20") to open an Alert, we cannot see the Alert and get Exception something like "org.openqa.selenium.UnhandledAlertException: Modal dialog present".
|
|
|
Post by leiwang on Feb 19, 2016 5:27:05 GMT
When the Alert popup is present, the UnhandledAlertException will be thrown out if we try to execute javascript through WebDriver or call API on WebDriver. According to link stackoverflow.com/questions/18336483/modal-dialog-present-exceptionYou don't see the Alert when you run the test is because the default behavior of the WebDriver is that it accepts alert when the Modal dialog present exception is thrown. It happens so fast that you can't see the alert. SeleniumPlus.Click() will firstly open the "Alert popup", then it will verify the click action does happen, which will call javascript code thru WebDriver, and UnhandledAlertException is thrown out. Selenium will close the "Alert popup" when meeting UnhandledAlertException.
|
|
|
Post by leiwang on Feb 19, 2016 5:30:55 GMT
There is a workaround code to show the "Alert popup" (and close it) as below:
WebElement we = SeleniumPlus.getObject(Map.WindowMain.ButtonToOpenAler); Point p = WDLibrary.getScreenLocation(we); p.translate(we.getSize().width/2, we.getSize().height/2); //Click to open the "Alert popup" org.safs.robot.Robot.click(p); Pause(1); //Press enter key to close the "Alert popup" SeleniumPlus.TypeKeys("{Enter}");
|
|
|
Post by leiwang on Feb 23, 2016 5:41:32 GMT
After the "Alert Modal Dialog" is present, don't call anything on WebDriver/SeleniumPlus (such as Component.GUIDoesNotExist(), Misc.WaitForGUI() etc.), which will throw UnhandledAlertException! To properly close this "Alert Modal Dialog", we can call WebDriver().switchTo().alert().accept();
|
|
|
Post by leiwang on Mar 2, 2016 8:50:07 GMT
Good news, we have implemented some new APIs to deal with Alert. SeleniumPlus.ClickUnverified() to open an Alert. Misc.AlertAccept() to close it (click ok button). Misc.AlertDismiss() to close it (click cancel button).
|
|
|
Post by leiwang on Oct 11, 2019 6:16:01 GMT
This UnhandledAlertException will not be thrown out anymore, in SeleniumPlus we have set the capability "UnexpectedAlertBehaviour" to "ignore", and that means the Alert dialog will be kept.
If user wants the other behavior, he can 1. Modify the setting in the .ini configuration file. [SAFS_TEST] ;UnexpectedAlertBehaviour=accept|dismiss|ignore|off (default: ignore)
2. Start the test with the JVM property setting -Dsafs.test.unexpected_alert_behaviour=accept|dismiss|ignore|off
|
|