selectWindow (window identifier) - Selenium IDE command

The selectWindow | tab=x and selectWindow | title=y commands switch between browser tabs. You can use it with title=(title of tab to be selected, * wildcard is supported) or use tab= with number of the tab (e. g 0,1,2,...). Tab=0 is the main window (the one the macro runs ins), tab=1 the first tab to the right, tab=2 the second, and so on. And tab=-1 is the tab to the left of the start tab (if there are any tabs to the left). So tab=-1 is the first tab to the left of the main tab, tab=-2 the second, and so on. "Main tab" is tab that is the active tab when the macro started (thus also called "start tab"). This also shows that the command name of selectWINDOW is somewhat outdated, it was coined when Internet Explorer still ruled the web. Today, "selectTab" would be the more appropriate term. We continue to use the old term "select Window" for backward and Selenium IDE compatibility.

selectWindow | TAB=OPEN | https://newwebsiteURL.com this opens a new tab and loads the website with the given URL.

selectWindow | TAB=CLOSE closes the current tab. It works the same way as if a user manually closes the tab. If there is a tab to the RIGHT of the closed tab, then Ui.Vision RPA makes it the current tab. If there is no tab to the RIGHT, then the tab LEFT of the closed tab becomes it the current tab. And if there is no other open tab, then TAB=CLOSE closes the browser.

selectWindow | TAB=CLOSEALLOTHER closes all open tabs except the current one. Together with deleteAllCookies it is a useful command to “clean up” at the start of a test.

You can retrieve the index of the current tab with two internal variables:
- ${!current_tab_number}gives you the absolute tab index (most leftmost browser tab is 0)
- ${!current_tab_number_relative} returns the relative tab index. Relative means relative to the macro start tab. Example: The relative index of the start tab is 0, the index of the first tab to its right is 1 and the index of the tab to its left (if any) is -1. This is the same value as used as input by the selectWindow | tab=X tab switching command above.

selectWindow Example

Command Target Pattern/Text
open https://ui.vision/
click link=Open one new browser window
selectWindow tab=1
click link=One more tab
selectWindow tab=2
verifyText link=Free Web Automation Free Web Automation
selectWindow tab=0 (this switches back to the first tab)
selectWindow tab=open https://ocr.space

Works in

Ui.Vision RPA for Chrome Selenium IDE, Ui.Vision RPA for Firefox Selenium IDE, Firefox IDE Classic

Related Demo Macros

DemoTabs

The ready-to-import-and-run source code of all demo macros can be found in the Open-Source RPA software Github repository.

See also

selectFrame, Web Automation Extension User Manual, Selenium IDE commands, Classic Firefox Selenium IDE.

Anything wrong or missing on this page? Suggestions?

...then please contact us.

<em>Ui.Vision RPA</em> Selenium IDE for Chrome and Firefox - Web Test Automation

Fresh from the Ui.Vision Forum: The Latest 3 RPA Software Discussions

← Meet the Ui.Vision team and users on our RPA software forum.