* Verifies that all CSS elements are as expected before taking a snapshot. * * @param {!puppeteer.Page} page a Puppeteer control browser tab/page. * @param {string} testName the full name of the test. * @param {!Array } selectors Array of CSS selector that must eventually * be remove
( page, testName, selectors, timeoutMillis = CSS_SELECTOR_TIMEOUT_MS )
| 23 | * @throws {Error} an encountered error. |
| 24 | */ |
| 25 | async function verifySelectorsInvisible( |
| 26 | page, |
| 27 | testName, |
| 28 | selectors, |
| 29 | timeoutMillis = CSS_SELECTOR_TIMEOUT_MS |
| 30 | ) { |
| 31 | log( |
| 32 | 'verbose', |
| 33 | 'Waiting for invisibility of all:', |
| 34 | cyan(selectors.join(', ')) |
| 35 | ); |
| 36 | try { |
| 37 | await Promise.all( |
| 38 | selectors.map((selector) => |
| 39 | waitForElementVisibility(page, selector, {hidden: true}, timeoutMillis) |
| 40 | ) |
| 41 | ); |
| 42 | } catch (e) { |
| 43 | throw new Error( |
| 44 | `${cyan(testName)} | An element with the CSS ` + |
| 45 | `selector ${cyan(e.message)} is still visible after ` + |
| 46 | `${CSS_SELECTOR_TIMEOUT_MS} ms` |
| 47 | ); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Verifies that all CSS elements are as expected before taking a snapshot. |
no test coverage detected