How can I focus on a newly opened window in Selenium IDE?
I am clicking on a link and a new tab will open. However I am not able to shift the focus to the new window.
I have tried this other SO answer, but it still doesn't work.
Here is the code that I have tried:
<tr>
<td>storeEval</td>
<td>selenium.getAllWindowTitles()[0]</td>
<td>windowName</td>
</tr>
<tr>
<td>getEval</td>
<td>this.doEcho("array length: "+selenium.getAllWindowNames().length);this.doEcho("Available window names: "+selenium.getAllWindowNames());this.doEcho("Selecting window: "+storedVars['windowName']);this.doEcho("Available window Titles: "+selenium.getAllWindowTitles());</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${windowName}</td>
<td></td>
</tr>
<tr>
<td>selectWindow</td>
<td>title=${windowName}</td>
<td></td>
</tr>
This code is using the current tab instead of the new tab and in echo it is printing the title of current tab and hence focussing again on current tab. When I use 1
instead of 0
in the array parameter (selenium.getAllWindowTitles()[1]
) in the first line, it is printing null
.
I have also tried with names instead of titles but it still does not work.