UNPKG

wdio-wait-for

Version:

a library of conditions that are useful for end-to-end tests

21 lines (20 loc) 777 B
import { getElement } from '../utils/index.js'; /** * A condition for checking an element contains a specific text * * @example * browser.waitUntil(textToBePresentInElement('.home', 'Home')); * * @param {!string | ChainablePromiseElement<WebdriverIO.Element>} selectorOrElement The selector or element to check * @param {!string} expectedText The expected text to verify * * @returns {!function} A condition that returns a promise * representing whether the element contains a specific text. */ export function textToBePresentInElement(selectorOrElement, expectedText) { return async function () { const element = await getElement(selectorOrElement); const text = await element.getText(); return text.includes(expectedText); }; }