This article serves as a reference for training test steps that interact with elements in iframes. Iframes, also known as inline frames, embed content from another website in an application, such as videos and maps.
Recording steps in iframes
When you record steps that interact with elements in an iframe, the mabl Trainer automatically detects the iframe and adds a switch context step before the recorded steps. When you interact with the rest of the page, the Trainer adds another switch context step to switch back to the root frame.
Training steps in an iframe and switching back to the root frame
If you are testing an application with nested iframes, the Trainer automatically adds a switch context step for each iframe you interact with.
Iframes with dynamic names
If the attributes of an iframe, such as its name or URL, change dynamically, use Configure Find to identify a fixed attribute by which to identify the iframe: … (More actions) > Configure Find.
For example, if an iframe's URL changes every time a test runs, but its name is always "childOne", update the switch context step to pick the iframe with the name "childOne":
Using Configure Find for iframes with dynamic attributes
Using XPath and CSS selectors in iframes
If you want to add custom find steps to target an element that exists within an iframe using XPath or CSS, make sure the Trainer is focused on the correct frame.
Before you record the custom find step, record a click step in the iframe to create a switch context step. By switching into the iframe, the mabl Trainer can search for the target element for the custom find step in the correct context.