# Wait For Selector

Source: https://docs.scrappey.com/docs/wait-for-selector

> Pause execution until a specific element appears in the DOM — ideal for waiting on AJAX content, modal windows, or any dynamically loaded section.

## Command

`"wait_for_selector"`

This action waits until a particular CSS selector appears on the page. It's useful for synchronization and ensuring elements are present before interacting with them.

## Parameters

| Parameter      | Type    | Required | Description                                                                                     |
| -------------- | ------- | -------- | ----------------------------------------------------------------------------------------------- |
| `cssSelector`  | string  | Yes      | The CSS selector to wait for. Example: `[class='col']`                                          |
| `timeout`      | number  | No       | Time in milliseconds to wait before timing out. Default is system-defined. Example: `30000`     |
| `when`         | string  | No       | When to run the check: `"beforeload"` or `"afterload"`. Default is `"afterload"`.               |
| `ignoreErrors` | boolean | No       | Set to `true` to continue even if the selector is not found.                                    |

## Example

```bash
curl -X POST "https://publisher.scrappey.com/api/v1?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cmd": "request.get",
    "url": "https://example.com",
    "browserActions": [
      {
        "type": "wait_for_selector",
        "cssSelector": "[class='\''example'\'']",
        "timeout": 30000
      }
    ]
  }'
```

## Notes

Use Case Ideas:

* Wait for content to load after an AJAX call before scraping.
* Detect when modals or confirmation boxes appear before clicking.
* Ensure dynamic tables or product listings are fully rendered.

Tips:

* Use `wait_for_selector` before actions like `click`, `type`, or `solve_captcha`.
* Combine with `ignoreErrors: true` if the element may not always appear, but scraping should continue.
