Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript function to call in order to click OK on confirmation dialog

Tags:

selenium

I am writing an automated test in Selenium IDE to test one of our applications. Our app throws one of those confirmation dialogs "Are you sure you want to continue." Click OK or Cancel

Selenium does not support the clicking of these dialog boxes. I have tried the following SeleniumIDE functions with no success:

chooseOkOnNextConfirmation
chooseOkOnNextConfirmationAndWait

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

like image 432
Thiyagarajan Veluchamy Avatar asked Jul 23 '12 07:07

Thiyagarajan Veluchamy


2 Answers

If you are working on 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();
like image 115
Sonu Avatar answered Sep 21 '22 00:09

Sonu


You are going to have to use JavascriptExecutor to press the OK or Cancel button while using Selenium. You could try something along the lines of -

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

That is of course, without seeing any of your code

like image 30
TheLifeOfSteve Avatar answered Sep 18 '22 00:09

TheLifeOfSteve