0

SeleniumIDE Issue - js alert() is not detected by IDE

These steps will reproduce the problem:

  1. Open http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert2
  2. Click on the "try it" button
  3. The clicking of OK on alert is not captured by IDE
1

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

| improve this answer | |
0

Look at the given link for example-

  1. How To Handle JavaScript Prompt Box: http://reditblog.blogspot.in/2014/11/how-to-handle-javascript-prompt-box.html

  2. How To Handle JavaScript Confirm Box: http://reditblog.blogspot.in/2014/11/how-to-handle-javascript-confirm-box.html

  3. How To Handle JavaScript Alert Box: http://reditblog.blogspot.in/2014/11/how-to-handle-javascript-alert-box.html

| improve this answer | |
  • Varun, the link may answer the question, but it's preferred that answers stand on their own instead of needing the link to be followed. Links should support already good answers, not be the entire answer. Also, if you're linking to something you yourself wrote you should include that in your answer. (Including the other answer that is letter for letter identical to this one...) – corsiKa Nov 10 '14 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.