MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / waitForText

Method waitForText

lib/helper/WebDriver.js:2601–2620  ·  view source on GitHub ↗

* {{> waitForText }} *

(text, sec = null, context = null)

Source from the content-addressed store, hash-verified

2599 *
2600 */
2601 async waitForText(text, sec = null, context = null) {
2602 const aSec = sec || this.options.waitForTimeoutInSeconds
2603 const _context = context || this.root
2604
2605 return this.browser.waitUntil(
2606 async () => {
2607 const res = await this.$$(withStrictLocator.call(this, _context))
2608 if (!res || res.length === 0) return false
2609 const selected = await forEachAsync(res, async el => this.browser.getElementText(getElementId(el)))
2610 if (Array.isArray(selected)) {
2611 return selected.filter(part => part.indexOf(text) >= 0).length > 0
2612 }
2613 return selected.indexOf(text) >= 0
2614 },
2615 {
2616 timeout: aSec * 1000,
2617 timeoutMsg: `element (${_context}) is not in DOM or there is no element(${_context}) with text "${text}" after ${aSec} sec`,
2618 },
2619 )
2620 }
2621
2622 /**
2623 * {{> waitForValue }}

Callers

nothing calls this directly

Calls 4

forEachAsyncFunction · 0.85
getElementIdFunction · 0.85
$$Method · 0.80
filterMethod · 0.80

Tested by

no test coverage detected