> ## Documentation Index
> Fetch the complete documentation index at: https://docs.testdriver.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# wait-for-text

> Wait until the specified text is detected on the screen.

<div className="replay-block">
  <iframe src="https://app.testdriver.ai/replay/68a594f73f4291f46c418d42?share=TMvd5NhizKhNsWnnuyl5A&embed=true&timestamp=90000&playbackRate=5" width="1000" height="350" />
</div>

```yaml highlight={14-17} theme={null}
version: 6.0.0
steps:
  - prompt: go to testdriver.ai and verify the page loads
    commands:
      - command: press-keys
        keys:
          - ctrl
          - l
      - command: type
        text: testdriver.ai
      - command: press-keys
        keys:
          - enter
      - command: wait-for-text
        text: Book a Demo
        timeout: 10000 # 10 seconds
```

## Description

The `wait-for-text` command waits until the specified text is detected on the screen. This is useful for ensuring that textual elements are present before proceeding with the next steps in a test.

## Arguments

|  Argument |    Type   | Description                                                                                                      |
| :-------: | :-------: | :--------------------------------------------------------------------------------------------------------------- |
|   `text`  |  `string` | The text to find on the screen.                                                                                  |
| `timeout` |  `number` | (Optional) The duration in milliseconds to wait for the text to appear. Default is `5000` (5 seconds).           |
|  `method` |   `enum`  | (Optional) The matching algorithm to use. Possible values are `ai` and `turbo`. Default is `turbo`               |
|  `invert` | `boolean` | (Optional) If set to `true`, the command will wait until the specified text is NOT detected. Default is `false`. |

## Example usage

```yaml theme={null}
command: wait-for-text
text: Copyright 2024
timeout: 5000
```

## Protips

* Use unique and specific text to improve detection accuracy.
* Adjust the `timeout` value based on the expected load time of the text to avoid unnecessary delays.

## Gotchas

* If the text doesn't appear within the specified `timeout`, the command will fail.
* Ensure the text matches exactly, as variations in font size, style, or screen resolution may affect detection accuracy.

***

The `wait-for-text` command is ideal for synchronizing tests with textual elements that may take time to load.
