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) or, often easier, 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 right of the start tab (if there is one). 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 for backward compatibility.

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.

selectWindow | TAB=OPEN | this opens a new tab and loads the website with the given URL.

selectWindow Example

Command Target Pattern/Text
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

Works in

Kantu for Chrome Selenium IDE, Kantu for Firefox Selenium IDE, Firefox IDE Classic

Related Demo Macros


The ready-to-import-and-run source code of all demo macros can be found in the Github repository testmacros folder.

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.

Kantu Selenium IDE for Chrome and Firefox - Web Test Automation
Subscribe to the a9t9 automation software newsletter . We'll send you updates on new releases that we're working on.