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



  • 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


  • 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



Suggested Topics