> For the complete documentation index, see [llms.txt](https://docs.testfirst.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.testfirst.com/testfirst-editor/advanced-test-capabilities/iframe-support.md).

# iFrame Support

TestFirst supports testing applications that use iFrames, including nested and embedded iFrame content.

Elements inside iFrames can be interacted with the same way as elements on the main page, whether tests are recorded using the Recorder or written manually using Gherkin.

### **Automatic iFrame Handling**

TestFirst automatically detects and handles iFrame boundaries during recording and execution.

In most cases, users do not need to manually switch into frames. Tests transparently pass through iFrame boundaries, including cross-origin iFrames, allowing elements inside iFrames to behave as if they were part of the main page.

This allows you to:

* Record interactions inside embedded frames reliably
* Execute tests across nested iFrame structures
* Work with pages containing multiple frames with similar elements
* Replay Recorder-generated tests across iFrame boundaries automatically

#### **Example**

In this example, the button exists inside an iFrame, but no manual frame switching is required.

```
Scenario: Interact with elements inside an iFrame  
Given browser "Chrome"  
When I visit "https://playground.testfirst-qa.com/iframe"  
And I click "'Click Me' button in 'Second Level Iframe' section"  
Then "'Button Clicked' message" is displayed
```

#### **Current Automatic Handling Limits**

Automatic iFrame traversal currently supports:

* Up to **20 visible iFrames** per page
* Up to **3 nested iFrame levels**

For more complex applications, manual iFrame handling can be used.

***

### **Improved / Manual iFrame Handling**

Although iFrame handling is automatic in most cases, users can explicitly focus test execution on a specific iFrame when needed.

This can be useful for:

* Very complex applications
* Large pages with many iFrame elements
* Improving selector precision
* Working around automatic traversal limits
* Deeply nested iFrame structures

#### **Switch to a Frame**

Use frame switching when you want to interact with elements inside a specific iFrame.

#### Example

```
Scenario: Work inside an iFrame  
Given browser "Chrome"  
When I visit "https://playground.testfirst-qa.com/iframe"  
And I switch to "frame-earth" frame  
Then "counter" is displayed
```

#### **Work with Nested Frames**

TestFirst also supports nested iFrames (iFrames inside other iFrames).

#### Example

```
Scenario: Work inside nested iFrames  
Given browser "Chrome"  
When I visit "https://playground.testfirst-qa.com/iframe"  
And I switch to "frame-earth" frame  
And I switch to "frame-moon" inner frame  
Then "counter" is displayed
```

#### **Remember Frames**

You can remember frames by name and switch back to them later.

This is useful for complex applications with multiple frame contexts.

#### Example

```
Scenario: Remember and switch between frames  
Given browser "Chrome"  
When I visit "https://playground.testfirst-qa.com/iframe"  
Then I remember "frame-earth" frame as "earth"

Scenario: Switch back to remembered frame  
When I switch to remembered frame "earth"  
Then "counter" is displayed
```

#### **Return to the Root Frame**

Use the root frame command to exit iFrame context and return to the main page.

#### Example

```
When I switch to root frame
```
