Skip to main content

basic-navigation Scenario 14 — Extract Text from an Iframe

Written by RTILA X Engineering Team

Advanced ~10 min
Prerequisites: basic-navigation/9 basic-navigation/10

What You'll Learn

Switch context into an iframe for content extraction

Real-World Use Case

Scraping embedded third-party widgets

LIVE DEMO

Iframe Content

An iframe rendered with srcdoc containing a guaranteed text node.

EXPECTED OUTPUT

Iframe Text

This content is loaded inside an iframe

RTILA X PROJECT JSON

RTILA X Automation Project

extract-iframe-text.json
    {
  "name": "Extract_Text_From_Iframe",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/basic-navigation/14"
    ]
  },
  "datasets": {
    "iframe_text": {
      "item_selector": "css=html",
      "properties": [
        {
          "name": "iframe_content",
          "type": "text",
          "selector": "css=.iframe-content"
        }
      ]
    }
  },
  "commands": [
    {
      "command": "goto",
      "params": {
        "url": "https://learn.rtila.com/scenarios/basic-navigation/14"
      }
    },
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=iframe#content-frame"
      }
    },
    {
      "command": "extract_data",
      "params": {
        "dataset": "iframe_text",
        "iframe": "css=iframe#content-frame"
      }
    }
  ]
}
  

RTILA X Concepts

When extraction must occur inside an iframe, pass the iframe parameter to extract_data. RTILA X switches the browser context into the iframe before resolving the dataset selectors.

Did you complete this scenario?

Ready to run this automation?

Copy the project JSON above, open RTILA X, create a new project, and paste it.

This scenario covers 2 RTILA X commands and is referenced in 2 learning articles.

Continue Learning

Was this helpful?