Skip to main content

error-handling Scenario 3 — Handle HTTP 429 with Retry-After

Written by RTILA X Engineering Team

Intermediate ~6 min
Prerequisites: error-handling/1 error-handling/2

What You'll Learn

Simulate offline conditions and retry

Real-World Use Case

Testing network resilience

LIVE DEMO

HTTP 429 Retry

A rate-limited status that unlocks after the Retry-After window.

Status: 429 Too Many Requests
Retry-After: 5 seconds
EXPECTED OUTPUT

API Data

endpoint status latency
/api/status 200 142ms
/api/status 200 138ms
/api/status 200 151ms
RTILA X PROJECT JSON

RTILA X Automation Project

handle-http-429-retry-after.json
{
  "name": "Handle_HTTP_429_Retry_After",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/error-handling/3"
    ]
  },
  "datasets": {
    "api_data": {
      "item_selector": "css=table.rate-limit-data tbody tr",
      "properties": [
        {
          "name": "endpoint",
          "type": "text",
          "selector": "css=td:nth-child(1)"
        },
        {
          "name": "status",
          "type": "text",
          "selector": "css=td:nth-child(2)"
        },
        {
          "name": "latency",
          "type": "text",
          "selector": "css=td:nth-child(3)"
        }
      ]
    }
  },
  "commands": [
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=.api-status"
      }
    },
    {
      "command": "execute_script",
      "params": {
        "script": "return document.querySelector('.api-status').textContent.includes('429') ? 'true' : 'false';",
        "output_variable": "status_429"
      }
    },
    {
      "command": "if",
      "params": {
        "condition": {
          "type": "variable_contains",
          "variable": "status_429",
          "value": "true"
        },
        "then": [
          {
            "command": "wait",
            "params": {
              "timeout": 5000
            }
          },
          {
            "command": "goto",
            "params": {
              "url": "https://learn.rtila.com/scenarios/error-handling/3"
            }
          }
        ],
        "else": []
      }
    },
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=.api-data"
      }
    },
    {
      "command": "extract_data",
      "params": {
        "dataset": "api_data"
      }
    }
  ]
}

RTILA X Concepts

HTTP 429 responses include a Retry-After hint. The automation detects the rate-limit status, waits for the suggested delay, and navigates again to access the successful API data.

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 1 learning article.

Continue Learning

Was this helpful?