---
title: "frameLocator(selector) | Grafana k6 documentation"
description: "Browser module: frameLocator.frameLocator(selector) method"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# frameLocator(selector)

Returns a [FrameLocator](/docs/k6/next/javascript-api/k6-browser/framelocator/) for a nested iframe that matches the given `selector` within this frame. Use this to chain frame locators for nested iframes.

Expand table

| Parameter | Type   | Description                                                                                            |
|-----------|--------|--------------------------------------------------------------------------------------------------------|
| selector  | string | A selector that resolves to an iframe element (for example `iframe#inner` or `iframe[name="nested"]`). |

### Returns

Expand table

| Type                                                                  | Description                                     |
|-----------------------------------------------------------------------|-------------------------------------------------|
| [FrameLocator](/docs/k6/next/javascript-api/k6-browser/framelocator/) | A `FrameLocator` for the matched nested iframe. |

### Example

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import { browser } from 'k6/browser';

export const options = {
  scenarios: {
    browser: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
};

export default async function () {
  const page = await browser.newPage();

  try {
    await page.setContent(`
      <iframe id="outer" srcdoc="<iframe id='inner' srcdoc='<button>Submit</button>'></iframe>"></iframe>
    `);

    // Nested iframes: outer frame, then inner frame, then element
    const button = page.frameLocator('#outer').frameLocator('#inner').locator('button');
    await button.click();
  } finally {
    await page.close();
  }
}
```
