# waitUntil

This wait command is your universal weapon if you want to wait on something. It expects a condition and waits until that condition is fulfilled with a truthy value to be returned.

A common example is to wait until a certain element contains a certain text (see example).

## Usage[​](#usage "Direct link to Usage")

```
await browser.waitUntil(condition, { timeout, timeoutMsg, interval })
```

## Parameters[​](#parameters "Direct link to Parameters")

| Name                                 | Type               | Details                                                                                                                                             |
| ------------------------------------ | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `condition`                          | `Function`         | condition to wait on until returning a truthy value                                                                                                 |
| `options`<br />*optional*            | `WaitUntilOptions` | command options                                                                                                                                     |
| `options.timeout`<br />*optional*    | `Number`           | time in ms (default set based on [`waitforTimeout`](/docs/configuration.md#waitfortimeout) config value)                                            |
| `options.timeoutMsg`<br />*optional* | `String, Function` | error message to throw when waitUntil times out. A function is evaluated only after the timeout, so the message can include state from that moment. |
| `options.interval`<br />*optional*   | `Number`           | interval between condition checks (default set based on [`waitforInterval`](/docs/configuration.md#waitforinterval) config value)                   |

## Examples[​](#examples "Direct link to Examples")

index.html

```
loading...
```

[View on GitHub](https://github.com/webdriverio/example-recipes/blob/0bfb2b8d212b627a2659b10f4449184b657e1d59/waitUntil/index.html#L3-L8)

waitUntilExample.js

```
loading...
```

[View on GitHub](https://github.com/webdriverio/example-recipes/blob/0c9252b0a4f7e18a34cece74e5798c1fe464c120/waitUntil/waitUntilExample.js#L16-L24)

## Returns[​](#returns "Direct link to Returns")

* **\<Boolean>** **`return`:** true if condition is fulfilled
