Skip to main content

error-handling Scenario 1 — Retry Flaky Page 3 Times

Written by RTILA X Engineering Team

Beginner ~4 min

What You'll Learn

Check element visibility before acting

Real-World Use Case

Avoiding flaky tests on dynamic pages

LIVE DEMO

Loading...
EXPECTED OUTPUT

RTILA X PROJECT JSON

    {
  "name": "Retry_Flaky_Page",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/error-handling/1"
    ]
  },
  "datasets": {
    "flaky_data": {
      "item_selector": "css=table.flaky-data tbody tr",
      "properties": [
        {
          "name": "id",
          "type": "text",
          "selector": "css=td:nth-child(1)"
        },
        {
          "name": "product",
          "type": "text",
          "selector": "css=td:nth-child(2)"
        },
        {
          "name": "sku",
          "type": "text",
          "selector": "css=td:nth-child(3)"
        },
        {
          "name": "price",
          "type": "text",
          "selector": "css=td:nth-child(4)"
        }
      ]
    }
  },
  "commands": [
    {
      "command": "try_catch",
      "params": {
        "try": [
          {
            "command": "wait_for_selector",
            "params": {
              "selector": "css=.flaky-data",
              "timeout": 5000
            }
          },
          {
            "command": "extract_data",
            "params": {
              "dataset": "flaky_data"
            }
          }
        ],
        "catch": [
          {
            "command": "wait",
            "params": {
              "timeout": 5000
            }
          },
          {
            "command": "goto",
            "params": {
              "url": "https://learn.rtila.com/scenarios/error-handling/1"
            }
          },
          {
            "command": "wait_for_selector",
            "params": {
              "selector": "css=.flaky-data"
            }
          },
          {
            "command": "extract_data",
            "params": {
              "dataset": "flaky_data"
            }
          }
        ]
      }
    }
  ]
}
  

RTILA X Concepts

A try_catch block first waits for the target table with a short timeout. If the element does not appear, the catch branch waits, reloads the page, and attempts extraction again.

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?