0
votes

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?

7

7 Answers

1
votes

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.

0
votes

Sometime giving an explicit window locator type helps. Specify that you are giving a window title by prefixing your title with a title= to the selectWindow or selectPopup command as below.

selectWindow  title=my window title
0
votes

This may work for you

click               link=activate
waitForPageToLoad   
selectWindow        Third party activation site

or try this

[info] Executing: |storeEval | this.browserbot.findElement('link=Pastanet').href | Link_PastaNet |
[info] Executing: |openWindow | ${Link_PastaNet} | MyWindows | 
0
votes

no solution, but I have a similar issue it seems to me, that there is a problem with background windows. if the window you want to select is behind another window, you cannot select it - it only works if the window is already in front

0
votes

user2989297 and Samit Badle are correct, but I found their answers very vague and confusing until I ran across another post that helped me put it all together.

The trick is to Assign your own name to the window you want to select, during the openWindow call. That is the purpose of the stored variable, though it isn't clear in the example above. I would suggest the following may be more easily understood.

<tr>
    <td>storeAttribute</td>
    <td>//table[@id='dtgList']/tbody/tr[1]/td/a@href</td>
    <td>varNewWindowName</td>
</tr>
<tr>
    <td>echo</td>
    <td>${varNewWindowName}</td>
    <td></td>
</tr>
<tr>
    <td>openWindow</td>
    <td>${varNewWindowName}</td>
    <td>Profile</td>  - this is where we assign it a new name, 'Profile'
</tr>
<tr>
    <td>pause</td>
    <td>10000</td>
    <td></td>
</tr>
<tr>
    <td>selectWindow</td>
    <td>Profile</td> - now we can select it, using the new name
    <td></td>
</tr>

If you're working in the Selenium IDE, the equivalent commands are;

    Command: storeAttribute
    Target: //table[@id='dtgList']/tbody/tr[1]/td/a@href
    Value: varNewWindow

    Command: echo - I've read that the echo command is optional, but I used it
    Target: ${varNewWindow}
    Value: 

    Command: openWindow
    Target: ${varNewWindow}
    Value: Profile - again, this is where we assign the new name

    Command: Pause
    Target: 10000
    Value:

    Command: selectWindow
    Target: Profile - and then use the new name
    Value: 
0
votes

I can see this issue was popular in Selenium IDE ...for now, i have an easy way to solve this issue . Why you don't create a new Test Case ? it will select New Window or Popup as you want

-1
votes

The best solution is to leave empty the target & put the title as a value.

Command: selectPopUp
Target: 
Value: Your popUp title