> ## Documentation Index
> Fetch the complete documentation index at: https://stagehand-codex-replicate-pr-2348.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Working with iframes

### What is an iframe?

Iframes embed other pages within your current page. Sites use them for consent banners, payment widgets, chat bubbles, and third-party content.
Elements inside iframes exist in a separate context than the main page.

### Enable iframe support

Set `iframes: true` in your `act()`, `observe()`, and `extract()` commands.

<CodeGroup>
  ```typescript TypeScript theme={null}
  // Act within iframes
  await page.act({ action: "click the accept cookies button", iframes: true });

  // Observe within iframes
  const results = await page.observe({
    instruction: "Find the primary action button",
    iframes: true,
  });

  // Extract from iframes
  const data = await page.extract({
    instruction: "Extract the product price from the payment widget",
    schema: z.object({
      price: z.string(),
    }),
    iframes: true,
  });
  ```

  ```python Python theme={null}
  # Act within iframes
  await page.act(
      "click the accept cookies button",
      iframes=True
  )

  # Observe within iframes
  results = await page.observe({
      "instruction": "Find the primary action button",
      "iframes": True,
  })

  # Extract from iframes
  data = await page.extract({
      "instruction": "Extract the product price from the payment widget",
      "schema": {
          "type": "object",
          "properties": {
              "price": {"type": "string"}
          }
      },
      "iframes": True,
  })
  ```
</CodeGroup>

### Tips

* Iframes can increase processing time. For best performance, use the iframe option only when necessary.
* When you are unsure whether an element will be in an iframe, you can verify the presence of iframes in Stagehand logs.
* If an element intermittently fails to be found, it may be inside a lazy‑loaded iframe. Add small waits between steps or re‑run your action.

<Note>
  You can enable experimental features (like Shadow DOM support) via your Stagehand configuration. See the [configuration guide](/v2/configuration/browser).
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Analyze pages with observe()" icon="magnifying-glass" iconType="sharp-solid" href="/v2/basics/observe">
    Use `observe()` to plan precise, single-step actions before executing them.
  </Card>

  <Card title="Extract data with extract()" icon="table" iconType="sharp-solid" href="/v2/basics/extract">
    Use `extract()` with a data schema to pull clean, typed data from any page.
  </Card>

  <Card title="Caching actions" icon="bolt" iconType="sharp-solid" href="/v2/best-practices/caching">
    Speed up repeated automations by caching actions.
  </Card>

  <Card title="Act fundamentals" icon="arrow-pointer" iconType="sharp-solid" href="/v2/basics/act">
    Learn how to perform single-step actions reliably with `act()`.
  </Card>
</CardGroup>
