View Source Improve this doc

waitForText

Wait for an element (selected by css selector) for the provided amount of milliseconds to have text/content. If multiple elements get queried by a given selector, it returns true (or false if reverse flag is set) if at least one element has text/content.

Usage

1
browser.waitForText(selector[,ms][,reverse]);

Parameters

Param Type Details
selector String element to wait for
ms
optional
Number time in ms (default: 500)
reverse
optional
Boolean if true it waits for the opposite (default: false)

Example

index.html
1
2
3
4
5
6
<div id="elem"></div>
<script type="text/javascript">
setTimeout(function () {
document.getElementById('elem').innerHTML = 'some text';
}, 2000);
</script>
waitForTextExample.js
1
2
3
4
5
6
7
it('should detect when element has text', function () {
browser.waitForText('#elem', 3000);

// same as
elem = $('#elem');
elem.waitForText(3000)
});

Uses