Scenarios & Steps
Scenarios are sequences of steps that result in captured assets. They can be recorded interactively or written manually.
Scenario Structure
JSON
{
"scenarios": [
{
"name": "user-login",
"steps": [
{ "action": "goto", "url": "/login" },
{ "action": "type", "selector": "#email", "text": "user@example.com" },
{ "action": "type", "selector": "#password", "text": "password123" },
{ "action": "click", "selector": "button[type='submit']" },
{ "action": "waitFor", "selector": "[data-testid='dashboard']" },
{ "action": "capture", "key": "dashboard-logged-in" }
]
}
]
}
Step API Reference
| Action | Required Fields | Optional Fields | Description |
|---|---|---|---|
goto | url | - | Navigates to a specific URL |
click | selector | description | Clicks an element |
type | selector, text | - | Types text into an input |
hover | selector | - | Hovers over an element |
wait | - | ms | Pauses execution |
waitFor | selector | timeout | Waits until element is visible |
capture | key | selector, clip, crop | Takes a screenshot |
Step Examples
Navigation
JSON
{ "action": "goto", "url": "/dashboard" }
Click
JSON
{ "action": "click", "selector": "[data-testid='submit-btn']" }
Type
JSON
{ "action": "type", "selector": "#search", "text": "documentation" }
Hover (for menus)
JSON
{ "action": "hover", "selector": "[data-testid='dropdown-trigger']" }
Wait (fixed delay)
JSON
{ "action": "wait", "ms": 1000 }
Wait For Element
JSON
{ "action": "waitFor", "selector": ".loading-complete", "timeout": 5000 }
Capture
JSON
{ "action": "capture", "key": "settings-page" }
Selectors
Reshot supports multiple selector formats:
| Type | Example |
|---|---|
| CSS | .btn-primary, #submit |
| Playwright Locators | role=button[name="Save"], text="Welcome" |
| Attributes | [data-testid="nav-menu"] |
Prefer data-testid attributes for the most stable selectors that won't break when styles change.
Scenario Options
JSON
{
"name": "checkout-flow",
"timeout": 60000,
"viewport": {
"width": 1920,
"height": 1080
},
"steps": [...]
}
Scenario-level settings override global config.