Nick
Nick

Reputation: 11

Closing pop up frames with Selenium IDE

I am using Selenium IDE for some tests. But hardly stuck with one action - i need to close a download pop up window in FF.

Common way to perform this would be using selectWindow command, BUT - my pop up - it's actually a frame, so it does not have an ID and other useful parameters for IDE.

All my attempts to close this pop up lead to closing main window. I tried something like this, but did not work either:

<tr>
    <td>click</td>
    <td>css=#fpm &gt; img</td>
    <td></td>
</tr>
<tr>
    <td>waitForFrameToLoad</td>
    <td>http://www.somesite.com/lg/c.do?proj=1111&amp;aid=1111&amp;rnd=0.132456</td>
    <td></td>
</tr>
<tr>
    <td>pause</td>
    <td>5000</td>
    <td></td>
</tr>
<tr>
    <td>close</td>
    <td></td>
    <td></td>
</tr>
<tr>

Is anybody faced this problem in the past? I know, that JS can be used at this point, but i don't have any clue how. Can you advise?

Upvotes: 1

Views: 3692

Answers (1)

Nick
Nick

Reputation: 11

Finally, i found a way... Bit tricky, but it works. So, this was an IDE bug, where IDE is unable to identify opened "_blank" windows. Here is workaround:

<tr>
    <td>storeAttribute</td>
    <td>//a[@'Here you can use id/class/href/rel link, etc, for ex: @rel='Register']/@href</td>
    <td>href</td>
</tr>
<tr>
    <td>openWindow</td>
    <td>${href}</td>
    <td></td>
</tr>
<tr>
    <td>pause</td>
    <td>2000</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>selenium.getAllWindowNames()[1];</td>  -- [1] - window to select from array of window names, 0 - it's a main, 1 - 1st opened pop up, 2 - 2nd, etc.
    <td>windowName</td>
</tr>
<tr>
    <td>pause</td>
    <td>2000</td>
    <td></td>
</tr>
<tr>
    <td>selectWindow</td>
    <td>${windowName}</td>
    <td></td>
</tr>
<tr>
    <td>verifyElementPresent</td>
    <td>Verify something here</td>
    <td></td>
</tr>
<tr>
    <td>close</td>  -- close pop up
    <td></td>
    <td></td>
</tr>
<tr>
    <td>selectWindow</td>  -- return to main window
    <td>null</td>
    <td></td>
</tr>

Upvotes: 0

Related Questions