Tabs & iframes

BugBug fully supports testing in iframes or multiple tabs. This is handled automatically during the recording but can also be controlled manually. You will notice the Switch context action if you work with iframes or multiple tabs.

What is the "Switch context" action?

When you record something in a different tab or iframe, an additional step will be recorded before the actual action for switching the context to this new frame or tab.

This defines the context for all the following test steps until you switch the context again to a different frame or a tab.

Locating the right frame

The first tab you visit during the test is Tab number 0 and context identified as Top. This is the default text execution context, and if you don't interact in your test with iframes or other tabs, you don't need to add the Switch context step.

The default test execution context is Tab number 0 and context Top, and adding this at the beginning of the test is unnecessary.

If you navigate to different tabs or iframes during the test, they will be identified by:

  • Tab number [number]

  • Context [Top|Iframe]

  • Frame element (if the context is Iframe)

Tabs are numerated from 0, so each frame you open during the recording session will have incremented numbers.

Tab numbers starting from 0

If the interaction is not in an Iframe, the context should be set to your default tab context: Top.

Default tab context - Top

If the interaction is inside an iframe, the context should be set to Iframe and the correct iframe selector is needed:

Switch to the iframe identified by XPath //IFRAME[id="frame1"] in the first browser tab (tab 0)

BugBug also supports nested iframes during a regular recording session. You can read more about nested selectors here.

Switch test execution context to nested iframe

A test scenario when you operate in your first tab, then in an iframe, in the nested iframe, and then again in the first tab looks like the below:

Mixed test contexts

If you have mixed contexts in your tests, it's important to remember which context you're in to make sure the test works correctly.

Last updated

Was this helpful?