View Source Improve this doc

waitForExist

Wait for an element (selected by css selector) for the provided amount of milliseconds to be present within the DOM. Returns true if the selector matches at least one element that exists in the DOM, otherwise throws an error. If the reverse flag is true, the command will instead return true if the selector does not match any elements.

Usage

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

Parameters

Param Type Details
selector String CSS selector to query
ms
optional
Number time in ms (default: 500)
reverse
optional
Boolean if true it instead waits for the selector to not match any elements (default: false)

Example

waitForExistSyncExample.js
1
2
3
4
5
6
7
8
it('should display a notification message after successful form submit', function () {
var form = $('form');
var notification = $('.notification');
form.submit();
notification.waitForExist(5000); // same as `browser.waitForExist('.notification', 5000)`
expect(notification.getText()).to.be.equal('Data transmitted successfully!')
});

Uses