Skip to main content

error-handling Scenario 2 — Fallback Selector on Extraction Failure

Written by RTILA X Engineering Team

Beginner ~4 min

What You'll Learn

Assert computed styles to verify UI state

Real-World Use Case

Validating that a hidden element is truly hidden

LIVE DEMO

Fallback Selector

Only the legacy table exists; the fallback dataset captures it.

IDNameStatus
1Project AlphaActive
2Project BetaPending
3Project GammaActive
4Project DeltaPaused
5Project EpsilonActive
EXPECTED OUTPUT

Fallback Data

row_id name status
1 Project Alpha Active
2 Project Beta Pending
3 Project Gamma Active
4 Project Delta Paused
5 Project Epsilon Active
RTILA X PROJECT JSON

RTILA X Automation Project

fallback-selector-extraction.json
{
  "name": "Fallback_Selector_Extraction",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/error-handling/2"
    ]
  },
  "datasets": {
    "fallback_data": {
      "item_selector": "css=.data-table tbody tr",
      "properties": [
        {
          "name": "row_id",
          "type": "text",
          "selector": "css=td:nth-child(1)"
        },
        {
          "name": "name",
          "type": "text",
          "selector": "css=td:nth-child(2)"
        },
        {
          "name": "status",
          "type": "text",
          "selector": "css=td:nth-child(3)"
        }
      ]
    },
    "fallback_data_legacy": {
      "item_selector": "css=.legacy-table tbody tr",
      "properties": [
        {
          "name": "row_id",
          "type": "text",
          "selector": "css=td:nth-child(1)"
        },
        {
          "name": "name",
          "type": "text",
          "selector": "css=td:nth-child(2)"
        },
        {
          "name": "status",
          "type": "text",
          "selector": "css=td:nth-child(3)"
        }
      ]
    }
  },
  "commands": [
    {
      "command": "try_catch",
      "params": {
        "try": [
          {
            "command": "wait_for_selector",
            "params": {
              "selector": "css=.data-table",
              "timeout": 5000
            }
          },
          {
            "command": "extract_data",
            "params": {
              "dataset": "fallback_data"
            }
          }
        ],
        "catch": [
          {
            "command": "comment",
            "params": {
              "text": "Primary selector failed, using fallback"
            }
          },
          {
            "command": "extract_data",
            "params": {
              "dataset": "fallback_data_legacy"
            }
          }
        ]
      }
    }
  ]
}

RTILA X Concepts

When a primary selector is missing, the catch block can execute a fallback extraction using an alternative selector. This keeps the automation running even when the DOM changes.

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 1 RTILA X command and is referenced in 1 learning article.

Continue Learning

Was this helpful?