waitForVisible

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

Usage

1
browser.waitForVisible(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" style="visibility: hidden;">Hello World!</div>
<script type="text/javascript">
setTimeout(function () {
document.getElementById('elem').style.visibility = 'visible';
}, 2000);
</script>
waitForVisibleExample.js
1
2
3
4
5
6
7
it('should detect when element is visible', function () {
browser.waitForVisible('#elem', 3000);

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

Uses