Javascript to invoke to click OK in the confirmation dialog

I am writing an automated test in the Selenium IDE to test one of our applications. Our application displays one of these confirmation dialog boxes, "You are sure you want to continue." Click OK or Cancel

Selenium does not support clicking on these dialog boxes. I have not performed the following SeleniumIDE functions:

chooseOkOnNextConfirmation chooseOkOnNextConfirmationAndWait 

Is there a JavaScript function that I can call in SeleniumIDE to do this, or am I out of luck.

+4
source share
2 answers

If you are working with an IDE, the code should be

 Command : assertConfirmation Target : Are you sure you want to continue? 

This will help you for sure.

If you are working on WebDriver , then the code should be

 driver.switchTo().alert().accept(); 
+7
source

When using Selenium, you will have to use the JavascriptExecutor to click the OK or Cancel button. You can try something line by line -

 ((JavascriptExecutor)driver).executeScript("window.confirm = function(msg){return true;};"); 

This, of course, without seeing any of your code

+2
source

All Articles