Selenium IDE select window issue

seleniumselenium-ide

I'm having difficulty selecting a window that pops up using Selenium IDE. I've tried

selectWindow(title)

and

selectPopup(title)

but they don't seem to work. Once the window is selected, the

verifyTitle(title)

works just fine, so I started doing some testing and the tests were able to match to objects on the background window. So it seems that I'm failing to match to the window by title. I've also tried just using selectWindow / selectPopup with no parameters, but there's no change.

It is important to note that the window is launched through the click of a button, which also creates the name of the window based on its id which isn't available to Selenium, hence we need to launch based on title, not name, and I'm unable to use openWindow or similar since the url etc are generated by the underlying system. I just need a consistent way to select the popup.

Does anyone know how I can resolve this?

Best Answer

The issue you are facing is that there is a bug in selenium IDE where it can only recognize windows that IT opened. You are unable to select the new window with "selectWindow" because Selenium IDE did not "Open" the window. It "clicked" on the link, and the webpage "opened" the window.

The workaround is to use storeAttribute on the hyperlink element pointed @href to extract the url from the link and store it as a variable. Then use openWindow. So instead of:

<tr>
    <td>click</td>
    <td>//table[@id='dtgList']/tbody/tr[1]/td/a/u</td>
    <td></td>
</tr>
<tr>
    <td>pause</td>
    <td>10000</td>
    <td></td>
</tr>
<tr>
    <td>selectWindow</td>
    <td>Profile</td>
    <td></td>
</tr>

Use this tactic:

<tr>
    <td>storeAttribute</td>
    <td>//table[@id='dtgList']/tbody/tr[1]/td/a@href</td>
    <td>Profile</td>
</tr>
<tr>
    <td>echo</td>
    <td>${Profile}</td>
    <td></td>
</tr>
<tr>
    <td>openWindow</td>
    <td>${Profile}</td>
    <td></td>
</tr>
<tr>
    <td>pause</td>
    <td>10000</td>
    <td></td>
</tr>
<tr>
    <td>selectWindow</td>
    <td>Profile</td>
    <td></td>
</tr>

Hope that helps.

Related Topic