* 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)
| 209 | * error with the message value set to the CSS selector. |
| 210 | */ |
| 211 | async 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 | |
| 222 | module.exports = { |
| 223 | waitForPageLoad, |
no test coverage detected