waitForNoElement(selector [,options])

🚧

This is a TDK feature

This is not supported in Testim's visual editor

Waits for an element to no longer exist on the screen.

  • selector {string | TDKStepLocator} a CSS selector or smart locator.
  • options {object}
    • checkVisibility { boolean } whether or not to wait for the element to no longer be user visible rather then exist on the page - defaults to true.
  • returns: Promise that fulfills when the element is present.

For example:

// ✅ good, wait for the element
await waitForNoElement('.someSelector');
// ✅ good, wait for the element to be on the page but not for visibility
await waitForNoElement('.someSelector', {
  checkVisibility: false
});
// ✅ good, wait for the element by locator
await waitForNoElement(l('login-form'));

// ❌ need to pass an element in
await waitForNoElement();
// ❌ options is the second argument
await waitForNoElement({
  selector: '.foo',
  checkVisibility: true
});

Full Example

'use strict';

const { go, waitForNoElement, evaluate, test } = require('testim');

test("waitForNoElement", async () => {
    await go('http://jsbin.testim.io/tiq/1');
    await evaluate(() => setTimeout(function () {
        var divs = [].slice.call(document.querySelectorAll('div'));
        divs.forEach(function(div) {
            div.parentNode.removeChild(div);
        });
    }, 10));
    await waitForNoElement('div');
});