> 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.md).

# Advanced Test Capabilities

TestFirst Editor supports advanced testing scenarios that go beyond basic automation.

You can simulate real-world user behaviour, handle multiple sessions, and build dynamic, reusable tests, all within a single flow.

## Multi-Tab & Multi-Window Testing

You can work with **multiple tabs and browser instances** in the same test.

This allows you to automate complex scenarios such as:

* Navigating across multiple pages
* Comparing views in parallel
* Simulating multiple users or sessions

#### **Multi-Tab Example**

```
Scenario: Work with multiple 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"
    And I visit "https://www.testfirst.com/plans" in a new tab
    And I remember the new tab as "plans"
    And I switch to the tab remembered as "plans"
```

#### **Multi-Window Example**

```
Scenario: Use multiple browser instances
    Given browser "Chrome" as "second"
    When I visit "https://testfirst.com"
    And I switch to "second" browser instance
```

#### **What You Can Do**

* Open and switch between tabs
* Launch multiple browser instances
* Switch across tabs and instances
* Close tabs and sessions when done

💡 Always name tabs and browser instances for reliable switching.

***

## Data-Driven Testing with Variables

Use variables to make your tests dynamic and reusable.

#### Example

```
When I type "{{user.username}}" in "Username"
And I type "{{user.password}}" in "Password"
```

#### Benefits

* Avoid hardcoded values
* Reuse tests across environments
* Improve maintainability

***

## Reusable Logic with Fragments

Fragments allow you to reuse common steps across multiple test cases.

#### Example

```
Given fragment "TCF1"
And I run the fragment
```

#### Use Cases

* Login flows
* Setup steps
* Repeated navigation

{% hint style="info" %}
See [**Fragments**](/testfirst-editor/fragments.md) for full details.
{% endhint %}

***

## Dynamic Data Handling

You can generate, capture, and validate values during execution.

#### Example

```
And I type "Project-{{random value}}" in "Project Name"
And I save a value from "Project Name" element to "project" variable
Then "{{project}}" should be equal to "Project-{{random value}}"
```

#### Use Cases

* Unique data creation
* Capturing UI values
* Validating dynamic content

#### Best Practices

* Keep flows readable with clear naming
* Use variables instead of hardcoding
* Extract repeated logic into fragments
* Clean up tabs and browser instances

***

## **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
```

***

## Summary

Advanced capabilities allow you to:

* Handle **multi-tab and multi-window flows**
* Build **dynamic, data-driven tests**
* Reuse logic using **fragments**
* Automate **complex real-world scenarios**
