MCPcopy Index your code
hub / github.com/ampproject/amphtml / waitForSelectorExistence

Function waitForSelectorExistence

build-system/tasks/visual-diff/verifiers.js:211–220  ·  view source on GitHub ↗

* Wait until the CSS selector exists in the page or until timed out. * * Timeout is set to CSS_SELECTOR_RETRY_MS * CSS_SELECTOR_RETRY_ATTEMPTS ms. * * @param {!puppeteer.Page} page page to check the existence of the selector in. * @param {string} selector CSS selector. * @param {number} timeou

(page, selector, timeoutMillis)

Source from the content-addressed store, hash-verified

209 * error with the message value set to the CSS selector.
210 */
211async function waitForSelectorExistence(page, selector, timeoutMillis) {
212 const startTime = Date.now();
213 do {
214 if ((await page.$(selector)) !== null) {
215 return true;
216 }
217 await sleep(CSS_SELECTOR_RETRY_MS);
218 } while (Date.now() < startTime + timeoutMillis);
219 throw new Error(selector);
220}
221
222module.exports = {
223 waitForPageLoad,

Callers 1

verifySelectorsVisibleFunction · 0.85

Calls 2

nowMethod · 0.80
sleepFunction · 0.70

Tested by

no test coverage detected