Testim Documentation

Welcome to the Testim documentation. You'll find comprehensive guides to help you get started quickly, example code snippets, and tips for being more productive. You will also find details about advanced features that allow you to customize Testim to fit your environment or special testing conditions. Don't worry, we'll support you if you get stuck. Let's jump right in!

Guides    Changelog

waitForElement(selector [,options])

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');
});

Updated 26 days ago

waitForElement(selector [,options])


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.