error-handling Scenario 4 — Try-Catch with Screenshot on Failure
Written by RTILA X Engineering Team
Intermediate ~6 min
Prerequisites: error-handling/1 error-handling/2
What You'll Learn
Use try_catch to capture screenshots on failure
Real-World Use Case
Debugging automation runs without manual intervention
LIVE DEMO
Fallback: Used backup selector to extract data
| Field | Value |
|---|---|
| Backup ID | BKP-1001 |
| Mode | Fallback |
| Status | Recovered |
EXPECTED OUTPUT
RTILA X PROJECT JSON
{
"name": "Try_Catch_With_Screenshot",
"settings": {
"urls": [
"https://learn.rtila.com/scenarios/error-handling/4"
],
"headless": false,
"navigation_timeout": 30000,
"max_concurrent_workers": 1,
"humanoidEnabled": true,
"humanoidSensitivity": "medium"
},
"datasets": {
"fallback_data": {
"item_selector": "css=table.fallback-data tbody tr",
"properties": [
{
"name": "field",
"type": "text",
"selector": "css=td:nth-child(1)"
},
{
"name": "value",
"type": "text",
"selector": "css=td:nth-child(2)"
}
]
}
},
"commands": [
{
"command": "goto",
"params": {
"url": "https://learn.rtila.com/scenarios/error-handling/4"
}
},
{
"command": "try_catch",
"params": {
"try": [
{
"command": "click",
"params": {
"selector": "css=#risky-action"
}
},
{
"command": "wait_for_selector",
"params": {
"selector": "css=.action-success",
"timeout": 5000
}
},
{
"command": "extract_data",
"params": {
"dataset": "fallback_data"
}
}
],
"catch": [
{
"command": "screenshot",
"params": {
"path": "error-screenshot.png"
}
},
{
"command": "extract_data",
"params": {
"dataset": "fallback_data"
}
}
]
}
}
]
}
RTILA X Concepts
When an action fails, the catch block can save a screenshot for debugging and then continue with a fallback extraction. This preserves context while keeping the automation resilient.
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?
Thank you for your feedback!