Waits for a condition to evaluate to a "truthy" value. The condition may be specified by any function which
returns the value to be evaluated or a Promise to wait for.

An optional wait time can be specified, otherwise the global waitForConditionTimeout value will be used.

Usage

.waitUntil(conditionFn, [callback])
.waitUntil(conditionFn, [waitTimeMs], [callback])
.waitUntil(conditionFn, [waitTimeMs], [retryInterval], [callback])
.waitUntil(conditionFn, [waitTimeMs], [retryInterval], [message], [callback])

Example

describe('waitUntil Example', function() {
  it('demo Test', function(browser) {
    browser
      .url('https://nightwatchjs.org)
      .waitUntil(async function() {
        const title = await this.execute(function() {
          return document.title;
        });

        return title === 'Nightwatch.js';
      }, 1000);
  });
}

Parameters

Name Type description
conditionFn function

The condition to wait on, defined as function which returns a Promise

waitTimeMs
Optional
number

How long to wait for the condition to be true (in milliseconds).

retryInterval
Optional
number

The interval to use between checks (in milliseconds).

callback
Optional
Function

An optional callback which will be called with the result

W3C WebDriver spec