GXtest UI Commands - Handling multiple Windows / Tabs

Official Content
This documentation is valid for:

If your application automatically launches different windows/tabs (ie. after clicking on some link), you can handle test automation on top.

So, these commands are not intended to open links or actions in a new tab but to handle tabs that are opened by the SUT (system under test).

There are 2 simple commands to handle those tabs, SwitchWindow (to set the current tab where the following test commands will be executed) and CloseWindow (to close a tab).

Both need a "WindowID" parameter that needs to be named like the following rule:

  • win_ser_local: the first window opened using the Start command.
  • win_ser_1: the first opened tab
  • win_ser_2: the second opened tab
  • ... and so on. 

To better understand behavior, you can see the test example below.



Goal: To set the current browser window/tab to automate  


  • WindowID: a special string with window's ID [win_ser_local, win_ser_1, win_ser_2, ...]

Example of use: 




Goal: To close a previously opened window/tab   


  • WindowID: a special string with window's ID to close [win_ser_local, win_ser_1, win_ser_2, ...]

Example of use: 



This is an example of a UI test that opens a Chrome Browser, and handle 3 different tabs:

// Script generated using GXtest Recorder
//Set browser

//Start webdriver

// Open a "multi-tab" webpage:

// Let's open the first tab
&driver.ClickByLinkText("Click Here")
// Let's set the current tab as the recently opened one:
// Let's check that we are in the new tab: 
AssertStringEquals("New Window",&driver.GetTextByCSS("h3"),"problem on tab #1")

// Go back to the first tab:

// Open tab #2
&driver.ClickByLinkText("Click Here")
// Set current tab as the second one:
// Let's check that we also can do things there ....
AssertStringEquals("New Window",&driver.GetTextByCSS("h3"),"problem on tab #2")

// Close tab #2

// Close tab #1