# ScrapingBee HTML API JavaScript Scenarios
> Use `js_scenario` with the HTML API to interact with a rendered page before ScrapingBee returns its result.
## Request rules
- Send `js_scenario` as a JSON object; stringify it in a GET query string.
- Set `render_js=true`; scenarios and their reports require JavaScript rendering.
- API-level `wait_for` runs first, then API-level `wait`, then the scenario instructions execute sequentially in the listed order.
- Instructions execute sequentially in the order listed.
- CSS and XPath selectors work in every selector instruction. A selector beginning with `/` is XPath; all other selectors are CSS.
- Use `json_response=true` while developing scenarios. It returns `js_scenario_report`, and `evaluate` results appear in `evaluate_results`.
- A complete scenario must finish within 40 seconds.
```json
{
"instructions": [
{"wait_for_and_click": "#accept"},
{"fill": ["#search", "ScrapingBee"]},
{"wait": 1000},
{"scroll_y": 800}
]
}
```
## Strict mode
`strict` defaults to `true`: an instruction failure aborts the scenario and returns an error. Set `strict: false` only when later instructions can safely continue after an earlier failure.
```json
{
"strict": false,
"instructions": [{"wait_for_and_click": "#optional-banner"}]
}
```
## Instructions
| Instruction | Value | Behavior |
| --- | --- | --- |
| `click` | selector | Click an element. |
| `wait` | milliseconds | Wait a fixed duration. |
| `wait_for` | selector | Wait for an element to appear. |
| `wait_for_and_click` | selector | Wait for an element then click it; equivalent to `wait_for` followed by `click`. |
| `scroll_x` | pixels | Scroll horizontally. |
| `scroll_y` | pixels | Scroll vertically. |
| `fill` | `[selector, value]` | Fill an input. |
| `evaluate` | JavaScript source | Run page JavaScript. |
| `infinite_scroll` | configuration object | Scroll until the end of the page. |
### Infinite scroll
```json
{
"infinite_scroll": {
"max_count": 0,
"delay": 1000,
"end_click": {
"selector": "#load-more",
"selector_type": "css"
}
}
}
```
- `max_count` is the maximum scroll count; `0` means unlimited.
- `delay` is the wait between scrolls in milliseconds.
- `end_click` is optional and clicks a button at the end, commonly “load more”.
- `end_click.selector_type` is `css`, `auto`, or `xpath`; provide it when selector detection is insufficient.
- `infinite_scroll` is not supported with `stealth_proxy`.