Reputation: 67
I m using firefox 10 and selenium-server-standalone-2.25.0.jar . I am writing script using webdriver only. In my application there is one alert box with OK button. I try many code solution but does not work. Following are workarounds that i tried
Solution 1:
((JavascriptExecutor)driver).executeScript("window.alert = function(msg){};");
Solution 2:
Alert alert = driver.switchTo().alert();
alert.accept();
But It displays below error
Caused by: org.openqa.selenium.UnhandledAlertException: Modal dialog present
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
Upvotes: 0
Views: 766
Reputation: 5187
I suggest you the following solutions :
driver.switchTo().alert().dismiss()
;1 second
)UnhandledAlertException
exception and try to dismiss()
in the catch code.Tell me if something was useful for you
Upvotes: 2