Switch To Another Window/Iframe action: SWITCHTO
The Switch To Another Window/Iframe action allows you to switch between different browser windows, tabs, or iframes during automation. This is particularly useful when working with applications that open content in new windows or frames, ensuring that the automation can interact with the right element in the right context.
- Example 1: Switch to an iframe using the iframe’s locator.
Steps to configure:
- Select Switch To Another Window/Iframe from the Action drop-down.
- In the Element Key field, specify the locator of the iframe you want to switch to. This can be the locator of the element (such as an iframe ID or any locator present inside that iframe).
- Leave the Parameters field blank unless specific conditions apply.
- Click Save to add the step to your test case.
Note: While the steps for adding an Action are identical in both views, the display of the steps changes:


Note: Ensure that the Screen Name and Element Key are already defined before using this action.
Expected Outcome on Execution: The automation will switch focus to the specified iframe, enabling the script to interact with the new context.
- Example 2: Switch Back to the Main Window and Close All Child Windows: Let’s suppose after interacting with multiple child windows, you need to return to the main window (Home page) and close all child windows.
Steps to configure:
- Select Switch To Another Window/Iframe from the Action drop-down.
- In the Element Key field, specify the text as main to switch back to the main window and close all child windows.
- Leave the Parameters field blank.
- Click Save.
Note: While the steps for adding an Action are identical in both views, the display of the steps changes:


Expected Outcome on Execution: The automation will return focus to the main browser window (Home page) and close all open child windows. Any subsequent steps in the Case will be performed in the main window context, allowing interaction with elements outside of iframes or pop-up windows.
If the automation involves switching between multiple tabs or frames frequently, make sure each window or frame has a unique identifier for easy reference in the script.
- Example 3: Switch main/parent tab Without Closing Child Window:
Suppose want to switch focus back to the main tab without closing a child window. This is useful for cases where you need to interact with the original page without losing access to a pop-up or child window.
Steps to configure:
- Select Switch To Another Window/Iframe from the Action drop-down.
- In the Element Key field, specify the keyword default to switch to the previous tab (default content).
- In the Parameters field, specify the keyword tab.
- Click Save.
Note: While the steps for adding an Action are identical in both views, the display of the steps changes:


Expected Outcome on Execution: The automation will switch focus to the previous tab without closing any child windows. Any subsequent steps will execute in the context of the original tab, allowing access to elements outside of the current iframe or pop-up.