SeleniumIDE Issue - js alert() is not detected by IDE
These steps will reproduce the problem:
- Open http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert2
- Click on the "try it" button
- The clicking of OK on alert is not captured by IDE
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communitySeleniumIDE Issue - js alert() is not detected by IDE
These steps will reproduce the problem:
SeleniumIDE handles JavaScript alerts by not showing them at all. The problem is that this button and alert is generated in an iFrame, thus the resulting error message is also in the iFrame and cannot be handled unless it has focus.
Selenium handles iFrame as a sort of window, you first need to select it to interact with it.
Try these steps to verify it does indeed work:
<tr>
<td>open</td>
<td>http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert2</td>
<td></td>
</tr>
<tr>
<td>selectFrame</td>
<td>id=iframeResult</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>xpath=//button</td>
<td></td>
</tr>
Result is an message in the IDE console, instead of an JavaScript alertbox: [error] Error: There was an unexpected Alert! [Hello How are you?]
Also read this about handling javascript alerts with the Selenium IDE: https://stackoverflow.com/questions/14788118/selenium-ide-how-to-handle-java-script-alerts-and-confirmations
Look at the given link for example-
How To Handle JavaScript Prompt Box: http://reditblog.blogspot.in/2014/11/how-to-handle-javascript-prompt-box.html
How To Handle JavaScript Confirm Box: http://reditblog.blogspot.in/2014/11/how-to-handle-javascript-confirm-box.html
How To Handle JavaScript Alert Box: http://reditblog.blogspot.in/2014/11/how-to-handle-javascript-alert-box.html