/** * * @param {import('./config').Config} * @param {import('puppeteer').Frame | import('puppeteer').Page} page */ export function assertAccessibility(config: any, page: import('puppeteer').Frame | import('puppeteer').Page): Promise; /** * Asserts that a selector is not present in the passed page or frame. * * @example * ```javascript * await assertNotSelector(page, 'div[data-id="foo"] a.view', {message: 'Expected foo to not be present'}); * ``` * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} selector [CSS selector](https://www.w3.org/TR/2018/REC-selectors-3-20181106/#selectors) (aka query selector) of the targeted element. * @param {{timeout?: number, message?: string}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} message Error message shown if the element is not visible in time. * @param {number?} timeout How long to wait, in milliseconds. */ export function assertNotSelector(page: import('puppeteer').Page, selector: string, { timeout, message }?: { timeout?: number | undefined; message?: string | undefined; } | undefined): Promise; /** * Asserts that an element identified by a test ID (`data-testid=` attribute) is not present in the passed page or frame. * * @example * ```javascript * await assertNotTestId(page, 'foo', {message: 'Expected Test ID "foo" to not be present'}); * ``` * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} testId The test ID to look for. * @param {{timeout?: number, message?: string}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} message Error message shown if the element is not visible in time. * @param {number?} timeout How long to wait, in milliseconds. */ export function assertNotTestId(page: import('puppeteer').Page, testId: string, { timeout, message }?: { timeout?: number | undefined; message?: string | undefined; } | undefined): Promise; /** * Assert that there is currently no element matching the XPath on the page. * * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} xpath XPath to search for. * @param {{timeout?: number, message?: string, checkEvery?: number}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} message Error message shown if the element is not visible in time. * @param {number?} timeout How long to wait, in milliseconds. (Default: 2s) * @param {number?} checkEvery Intervals between checks, in milliseconds. */ export function assertNotXPath(page: import('puppeteer').Page, xpath: string, options: any, _timeout?: number, _checkEvery?: number): Promise; /** * Take a screenshot and compare it against an existing one. Any differences between * the two will be highlighted. * @param {import('./internal').TaskConfig} config * @param {import('puppeteer').Page} page * @param {string} name * @param {{ threshold?: number, selector?: string, fullPage?: boolean } & import('pixelmatch').PixelmatchOptions} [options] */ export function assertSnapshot(config: import('./internal').TaskConfig, page: import('puppeteer').Page, name: string, { threshold, selector, fullPage, ...pxl }?: ({ threshold?: number | undefined; selector?: string | undefined; fullPage?: boolean | undefined; } & pixelmatch.PixelmatchOptions) | undefined): Promise; /** * Assert an `` element having a certain value (after a wait if necessary). * * @param {import('puppeteer').ElementHandle} input A puppeteer handle to an input element. * @param {string} expected The value that is expected to be present. */ export function assertValue(input: import('puppeteer').ElementHandle, expected: string): Promise; /** * Click any element by its text content. * * The text can span multiple nodes. * * @param {import('puppeteer').Page} page puppeteer page object. * @param {string | RegExp} textOrRegExp Text or regex to match the text that the element must contain. * @param {{extraMessage?: string, timeout?: number, checkEvery?: number, visible?: boolean, assertSuccess?: () => Promise, retryUntil?: () => Promise}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {number?} timeout How long to wait, in milliseconds. * @param {number?} checkEvery Intervals between checks, in milliseconds. (default: 200ms) * @param {string?} extraMessage Optional error message shown if the element is not visible in time. * @param {boolean?} visible Optional check if element is visible (default: true) * @param {() => Promise?} assertSuccess Deprecated: Alias of retryUntil * @param {() => Promise?} retryUntil Additional check or assertion to verify that the operation was successful. This is needed in cases where a DOM node is present * and we clicked on it, but the framework that rendered the node didn't set up any event listeners yet. */ export function clickText(page: import('puppeteer').Page, textOrRegExp: string | RegExp, { timeout, checkEvery, extraMessage, visible, assertSuccess, retryUntil, }?: { extraMessage?: string | undefined; timeout?: number | undefined; checkEvery?: number | undefined; visible?: boolean | undefined; assertSuccess?: (() => Promise) | undefined; retryUntil?: (() => Promise) | undefined; } | undefined): Promise; /** * Clicks an element address ed by a query selector atomically, e.g. within the same event loop run as finding it. * * @example * ```javascript * await clickSelector(page, 'div[data-id="foo"] a.view', {message: 'Could not click foo link'}); * ``` * @param {import('puppeteer').Page | import('puppeteer').Frame} page puppeteer page object. * @param {string} selector [CSS selector](https://www.w3.org/TR/2018/REC-selectors-3-20181106/#selectors) (aka query selector) of the targeted element. * @param {{timeout?: number, checkEvery?: number, message?: string, visible?: boolean, assertSuccess?: () => Promise, retryUntil?: () => Promise}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} message Error message shown if the element is not visible in time. * @param {number?} timeout How long to wait, in milliseconds. * @param {number?} checkEvery How long to wait _between_ checks, in ms. (default: 200ms) * @param {boolean?} visible Whether the element must be visible within the timeout. (default: `true`) * @param {() => Promise?} assertSuccess Deprecated: Alias of retryUntil * @param {() => Promise?} retryUntil Additional check or assertion to verify that the operation was successful. This is needed in cases where a DOM node is present * and we clicked on it, but the framework that rendered the node didn't set up any event listeners yet. */ export function clickSelector(page: import('puppeteer').Page | import('puppeteer').Frame, selector: string, { timeout, checkEvery, message, visible, assertSuccess, retryUntil, }?: { timeout?: number | undefined; checkEvery?: number | undefined; message?: string | undefined; visible?: boolean | undefined; assertSuccess?: (() => Promise) | undefined; retryUntil?: (() => Promise) | undefined; } | undefined): Promise; /** * Click an element identified by a test ID (`data-testid=` attribute). * Selecting and clicking happens in the same tick, so this is safe to call even if the client application may currently be rerendering. * * @param {import('puppeteer').Page} page The puppeteer page handle. * @param {string} testId The test ID to look for. * @param {{extraMessage?: string, timeout?: number, visible?: boolean, assertSuccess?: () => Promise, retryUntil?: () => Promise}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} extraMessage Optional error message shown if the element is not present in time. * @param {number?} timeout How long to wait, in milliseconds. (default: true) * @param {() => Promise?} assertSuccess Deprecated: Alias of retryUntil * @param {() => Promise?} retryUntil Additional check or assertion to verify that the operation was successful. This is needed in cases where a DOM node is present * and we clicked on it, but the framework that rendered the node didn't set up any event listeners yet. */ export function clickTestId(page: import('puppeteer').Page, testId: string, { extraMessage, timeout, visible, assertSuccess, retryUntil, }?: { extraMessage?: string | undefined; timeout?: number | undefined; visible?: boolean | undefined; assertSuccess?: (() => Promise) | undefined; retryUntil?: (() => Promise) | undefined; } | undefined): Promise; /** * Clicks an element addressed by XPath atomically, e.g. within the same event loop run as finding it. * * ```javascript * await clickXPath( * page, '//article[.//h1//text()[contains(., "My form")]]/button', * {message: 'Could not find the button in the foobar form'} * ); * ``` * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} xpath XPath selector to match the element. * @param {{timeout?: number, checkEvery?: number, message?: string, visible?: boolean, assertSuccess?: () => Promise, retryUntil?: () => Promise}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} message Error message shown if the element is not visible in time. * @param {number?} timeout How long to wait, in milliseconds. * @param {number?} checkEvery How long to wait _between_ checks, in ms. (default: 200ms) * @param {boolean?} visible Whether the element must be visible within the timeout. (default: `true`) * @param {() => Promise?} assertSuccess Deprecated: Alias of retryUntil * @param {() => Promise?} retryUntil Additional check or assertion to verify that the operation was successful. This is needed in cases where a DOM node is present * and we clicked on it, but the framework that rendered the node didn't set up any event listeners yet. */ export function clickXPath(page: import('puppeteer').Page, xpath: string, { timeout, checkEvery, message, visible, assertSuccess, retryUntil, }?: { timeout?: number | undefined; checkEvery?: number | undefined; message?: string | undefined; visible?: boolean | undefined; assertSuccess?: (() => Promise) | undefined; retryUntil?: (() => Promise) | undefined; } | undefined): Promise; /** * Close a page (and its associated browser) * @param {import('puppeteer').Page} page puppeteer page object returned by `newPage`. */ export function closePage(page: import('puppeteer').Page): Promise; /** * Create a unique temporary user data directory. Will be automatically * deleted when the test completes * @param {import('./internal').TaskConfig} config * @returns {Promise} Path to temporary user data dir */ export function createUserProfileDir(config: import('./internal').TaskConfig): Promise; /** * Construct an XPath expression for an arbitrary string. * * @example * ```javascript * const searchString = `'"'`; * const page = await newPage(config); * await page.goto('https://github.com/boxine/pentf/blob/master/browser_utils.js'); * await page.waitForXPath(`//div[@class="repository-content"]//text()[contains(., ${escapeXPathText(searchString)})]`); * await closePage(); * ``` * @param {string} text The text to encode. This can be user input or otherwise contain exotic characters. */ export function escapeXPathText(text: string): string; /** * Retrieve attribute value of a DOM element. * * @param {import('puppeteer').Page} page The puppeteer page handle. * @param {string} selector Query selector for the element. * @param {string} name Attribute name. * @returns {Promise} The attribute value */ export function getAttribute(page: import('puppeteer').Page, selector: string, name: string): Promise; /** * Get all options of a ``. * @returns {Promise} e.g. `['Option A', 'Option B(***)', 'Option C']` */ export function getSelectOptions(page: import('puppeteer').Page, select: import('puppeteer').ElementHandle): Promise; /** * Get the text content of a given DOM Element. * * @param {import('puppeteer').Page} page The puppeteer page handle. * @param {string} selector Query selector. * @returns {Promise} Text content of the selected element. */ export function getText(page: import('puppeteer').Page, selector: string): Promise; /** * Render a HTML string as a PDF file. * * @param {*} config The pentf configuration object. * @param {string} path PDF file name to write to. * @param {string} html Full HTML document to render. * @param {*} modifyPage An optional async function to modify the `page` object. */ export function html2pdf(config: any, path: string, html: string, modifyPage?: any): Promise; /** * Intercept browser requests * @param {import('puppeteer').Page} page * @param {(request: import('puppeteer').Request) => Promise | void} fn */ export function interceptRequest(page: import('puppeteer').Page, fn: (request: any) => Promise | void): Promise; /** * Launch a new browser with puppeteer, with a new page (=Tab). The browser is completely isolated from any other calls. * Most interactions will be with the page, but you can get the browser using `await page.browser();`. * For more information about the page object, see the [puppeteer API documentation](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md). * * @example * ```javascript * const page = await newPage(config); * await page.goto('https://example.org/'); * await waitForText(page, 'More information'); * await closePage(page); * ``` * @param {import('./internal').TaskConfig} config The pentf configuration object. * @param {string[]} [chrome_args] Additional arguments for Chrome (optional). * @returns {import('puppeteer').Page} The puppeteer page handle. */ export function newPage(config: import('./internal').TaskConfig, chrome_args?: string[] | undefined): import('puppeteer').Page; /** * Add a callback to execute during the teardown phase of the test case. * @param {import('./internal').TaskConfig} config * @param {import('./internal').TeardownHook} callback */ export function onTeardown(config: import('./internal').TaskConfig, callback: import('./internal').TeardownHook): void; /** * Resizes the browser window so that the page matches the specified dimensions. * @param {import('./config').Config} config * @param {import('puppeteer').Page} page * @param {{ width: number, height: number }} dimensions */ export function resizePage(config: import('./config').Config, page: import('puppeteer').Page, { width, height }: { width: number; height: number; }): Promise; /** * Restore timeouts modified by [[speedupTimeouts]] * * @param {import('puppeteer').Page} page The puppeteer page handle. */ export function restoreTimeouts(page: import('puppeteer').Page): Promise; /** * Configure the browser's language. * * @param {import('puppeteer').Page} page The puppeteer page handle. * @param {string | string[]} lang Either be a single string (e.g. "en") or an array of supported languages (e.g. `['de-DE', 'en-US', 'gr']`) */ export function setLanguage(page: import('puppeteer').Page, lang: string | string[]): Promise; /** * Speed up all timeouts of calls to `setTimeout`/`setInterval`. * * @example * ```javascript * const page = await newPage(config); * await page.setContent('
Hello world
'); * await speedupTimeouts(page, {factor: 1000}); * await page.evaluate(() => { * window.setTimeout(() => console.log("will log almost immediately"), 2000); * }); * await restoreTimeouts(page); * await page.evaluate(() => { * window.setTimeout(() => console.log("will log after 2 seconds"), 2000); * }); * await closePage(page); * ``` * @param {import('puppeteer').Page} page The puppeteer page handle. * @param {{factor?: number, persistent?: boolean}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param number? factor Speedup factor (e.g. a timeout of 20 seconds with a speedup of 100 will fire after 200ms). (default: 100) * @param boolean? persistent Whether this change should persist in case of page navigation. Set this if the next line is `await page.goto(..)` or similar. (default: false) */ export function speedupTimeouts(page: import('puppeteer').Page, { factor, persistent }?: { factor?: number | undefined; persistent?: boolean | undefined; } | undefined): Promise; /** * * @param {import('./config').Config} config * @param {import('puppeteer').Page} page * @param {string} fileName * @param {string} [selector] */ export function takeScreenshot(config: import('./config').Config, page: import('puppeteer').Page, fileName: string, selector?: string | undefined): Promise; /** * Type text into an element identified by a query selector. * * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} selector selector [CSS selector](https://www.w3.org/TR/2018/REC-selectors-3-20181106/#selectors) (aka query selector) of the element to type in. * @param {string} text Text to type * @param {{message?: string, timeout?: number, delay?:bumber}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {number?} timeout How long to wait, in milliseconds. * @param {string?} message Message shown if the element can not be found. * @param {number?} delay Delay in ms between each keystroke (Default: 0) */ export function typeSelector(page: import('puppeteer').Page, selector: string, text: string, { message, timeout, delay }?: { message?: string | undefined; timeout?: number | undefined; delay?: any; } | undefined): Promise; /** * Wait for an element matched by a CSS query selector to become present on the page. * * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} selector Query selector, e.g. `div > a[href="/"]:visited` * @param {{timeout?: number, message?: string, visible?: boolean}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} [message] Error message shown if the element is not visible in time. * @param {number?} [timeout] How long to wait, in milliseconds. * @param {visible?} [visible] Whether the element must be visible within the timeout. (default: `true`) * @returns {Promise} A handle to the found element. */ export function waitForSelector(page: import('puppeteer').Page, selector: string, { message, timeout, visible, }?: { timeout?: number | undefined; message?: string | undefined; visible?: boolean | undefined; } | undefined): Promise; /** * Wait until a selector is gone from the page * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} selector [CSS selector](https://www.w3.org/TR/2018/REC-selectors-3-20181106/#selectors) (aka query selector) of the targeted element. * @param {{timeout?: number, message?: string, checkEvery?: number}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} message Error message shown if the element is not visible in time. * @param {number?} timeout How long to wait, in milliseconds. * @param {number?} checkEvery Intervals between checks, in milliseconds. */ export function waitForSelectorGone(page: import('puppeteer').Page, selector: string, { timeout, message, checkEvery }?: { timeout?: number | undefined; message?: string | undefined; checkEvery?: number | undefined; } | undefined): Promise; /** * Search for an element with the given `data-testid` attribute. * * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} testId The test id to search * @param {{extraMessage?: string, timeout?: number, visible?: boolean}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} extraMessage Error message shown if the element is not visible in time. * @param {number?} timeout How long to wait, in milliseconds. * @param {boolean?} visible Whether the element must be visible within the timeout. (default: `true`) * @returns {Promise} Handle to the element with the given test ID. */ export function waitForTestId(page: import('puppeteer').Page, testId: string, { extraMessage, timeout, visible, }?: { extraMessage?: string | undefined; timeout?: number | undefined; visible?: boolean | undefined; } | undefined): Promise; /** * Wait until a test-id is gone from the page * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} testid the testid to check for * @param {{timeout?: number, message?: string, checkEvery?: number}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} message Error message shown if the element is not visible in time. * @param {number?} timeout How long to wait, in milliseconds. * @param {number?} checkEvery Intervals between checks, in milliseconds. */ export function waitForTestIdGone(page: import('puppeteer').Page, testid: string, { timeout, message, checkEvery }?: { timeout?: number | undefined; message?: string | undefined; checkEvery?: number | undefined; } | undefined): Promise; /** * Wait for text to appear on the page. * * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} text String to look for. * @param {{timeout?: number, extraMessage?: string}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} extraMessage Error message shown if the element is not present in time. * @param {number?} timeout How long to wait, in milliseconds. * @returns {Promise} A handle to the text node. */ export function waitForText(page: import('puppeteer').Page, text: string, { timeout, extraMessage }?: { timeout?: number | undefined; extraMessage?: string | undefined; } | undefined): Promise; /** * Wait for an element matched by a CSS query selector to become visible. * Visible means the element has neither `display:none` nor `visibility:hidden`. * Elements outside the current viewport (e.g. you'd need to scroll) and hidden with CSS trickery * (opacity, overlaid with z-index, or permanently positioned outside the viewport) count as visible. * * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} selector Query selector, e.g. `div > a[href="/"]:visited` * @param {{timeout?: number, message?: string}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} [message] Error message shown if the element is not visible in time. * @param {number?} [timeout] How long to wait, in milliseconds. * @returns {Promise} A handle to the found element. */ export function waitForVisible(page: import('puppeteer').Page, selector: string, { timeout, message }?: { timeout?: number | undefined; message?: string | undefined; } | undefined): Promise; /** * Assert that there is currently no element matching the XPath on the page. * * @param {import('puppeteer').Page} page puppeteer page object. * @param {string} xpath XPath to search for. * @param {{timeout?: number, message?: string, checkEvery?: number}} [__namedParameters] Options (currently not visible in output due to typedoc bug) * @param {string?} message Error message shown if the element is not visible in time. * @param {number?} timeout How long to wait, in milliseconds. (Default: 2s) * @param {number?} checkEvery Intervals between checks, in milliseconds. */ export function waitForXPathGone(page: import('puppeteer').Page, xpath: string, { timeout, message, checkEvery }?: { timeout?: number | undefined; message?: string | undefined; checkEvery?: number | undefined; } | undefined): Promise; /** * @hidden */ export function workaround_setContent(page: any, html: any): Promise; import pixelmatch = require("pixelmatch"); export { clickText as clickNestedText };