1. Introduction
TF Automate supports multi-tab and multi-window testing, allowing you to run complex, real-world user flows involving multiple browser contexts within the same test case. Whether you're switching between product pages, simulating user behavior in different sessions, comparing views, or handling other advanced scenarios, this feature adds new power and flexibility to your automated test cases.
2. Multi-Tab Testing
You can open multiple tabs within the same browser instance, switch between them, remember specific tabs by name, and close them as needed.
Example: Open and Navigate Between Tabs
Gherkin Text:
Scenario: Open few tabs in the default browser instance, switch between tabs
Given browser "Chrome"
When I visit "https://www.testfirst.com"
And I click "!See What’s New"
And I switch to the new tab remembering it as "whats-new"
Result:
Gherkin Text:
And I visit "https://www.testfirst.com/plans" in a new tab
And I remember the new tab as "plans"
Result:

Gherkin Text:
And I switch to the default tab
And I switch to the tab remembered as "plans"
And I click "!Manual Testing"
And I switch to the default tab
And I close the tab remembered as "whats-new"
And I remember current tab as "first-default"
And I wait for 1 seconds
Result:

Key Steps Explained
Command |
Description |
visit "URL" in a new tab | Opens the URL in a new browser tab. |
switch to the new tab remembering it as "name" | Switches to the most recently opened tab and remembers it with a given name. |
switch to the tab remembered as "name" | Switches focus to a tab remembered by name |
close current tab | Closes the currently active tab. |
remember current tab as "name" | Assigns a name to the current tab for easy future reference. |
3. Multi-Window Testing
TF Automate also allows you to launch and control multiple browser instances. Each instance is independent and can have its own tabs, simulating separate user sessions or parallel workflows.
Example: Open a Second Browser Window
Gherkin Text:
Command | Description |
Given browser "Chrome" as "name" | Launches a new browser instance and assigns it a name. |
switch to "name" browser instance | Switches to the specified browser instance. |
close current browser instance | Closes the active browser instance. |
4. Switching Between Browser Instances
You can switch between multiple browser instances mid-test to coordinate actions across them.
Scenario: Switch between browser instances
When I switch to the default browser instance
And I wait for 1 second
And I switch to "second" browser instance
And I wait for 1 second
5. Switching Between Tabs Across Browser Instances
You can also switch tabs by name regardless of which browser instance they belong to.
Scenario: Switch between tabs in different browser instances
When I switch to the tab remembered as "first-default"
And I switch to the tab remembered as "whats-new"
And I wait for 1 second
6. Closing Browser Instances
When tests are done, you can clean up by closing individual or all browser instances.
Scenario: Close browser instances
Given browser "Chrome" as "third"
When I visit "testfirst.com"
And I close current browser instance
And I switch to the default browser instance
And I close "second" browser instance
And I visit "testfirst.com"
And I close current browser instance
And I wait for 1 second
7. Tips for Best Use
-
Always remember tabs and browser instances by name to switch between them reliably.
-
Use descriptive names like
"login-tab"
or"admin-window"
for readability. -
Close unused tabs or windows to improve test performance and maintain test clarity.
-
Switch back to the default tab/window before ending the test to ensure proper cleanup.
Comments
0 comments
Please sign in to leave a comment.