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

waitForText(selector, expectedValue [,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 its text equal to expected value.

  • selector {string | TDKStepLocator} a CSS selector or smart locator.
  • expectedValue { string or RegExp } the expected value of the element
  • 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 and the element text as expected.

For example:

// ✅ wait for the element to contain the word 'Hello!'
await waitForText('.someSelector', 'Hello!');
// ✅ wait for the element text to contain a `@`
await waitForText('.someSelector', /.*@.*/);
// ✅ same as above but with a smart locator
await waitForText(l('.someSelector'), /.*@.*/);
// ✅ wait for an element to contain a '@' but disregard it being visible
await waitForText('.someSelector', /.*@.*/, {
  checkVisibility: false
// ❌ need to pass text in
await waitForText('.someSelector');

// ❌ arguments are positional and not an object
await waitForText({
  selector: '.someSelector',
  text: 'foo',
  checkVisibility: false

Full Example:

'use strict';

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

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

Updated about a year ago

waitForText(selector, expectedValue [,options])

Suggested Edits are limited on API Reference Pages

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