waitForElement(selector [,options])


This is a TDK feature

This is not supported in Testim's visual editor

Waits for an element to exist on the screen and be visible.

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

For example:

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

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

Full Example

'use strict';

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

test("waitForElement", async () => {
    await go('http://jsbin.testim.io/quh/1');
    await waitForElement('button');