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 an truthy value. A condition can be either a promise or a command that returns a promise.

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

Usage

1
client.waitUntil(condition[,timeout][,interval]).then(callback);

Parameters

Param Type Details
condition Function/Promise condition to wait on
timeout
optional
Number timeout in ms (default: 500)
interval
optional
Number interval between condition checks (default: 250)

Example

example.html
1
2
3
4
5
6
<div id="someText">I am some text</div>
<script>
setTimeout(function() {
$('#someText').html('I am now different');
}, 1000);
</script>
waitUntil.js
1
2
3
4
5
client.waitUntil(function() {
return this.getText('#someText').then(function(text) {
return text === 'I am now different'
});
});

Uses