From 1716f3f5755fefcf04ad7a50527f17ab32128494 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Tue, 17 Mar 2020 22:07:34 +0100 Subject: [PATCH] feat(puppeteer): add page functions --- tools/puppeteer.js | 467 ++++++++++++++++++++++----------------------- 1 file changed, 233 insertions(+), 234 deletions(-) diff --git a/tools/puppeteer.js b/tools/puppeteer.js index bb6c7d5..3c2f936 100644 --- a/tools/puppeteer.js +++ b/tools/puppeteer.js @@ -117,135 +117,134 @@ browserContext.waitForTarget(predicate[, options]) // Promise which resolve const page = await browser.newPage(); -page.on('close') // -page.on('console') // -page.on('dialog') // -page.on('domcontentloaded') // -page.on('error') // -page.on('frameattached') // -page.on('framedetached') // -page.on('framenavigated') // -page.on('load') // -page.on('metrics') // -page.on('pageerror') // -page.on('popup') // -page.on('request') // -page.on('requestfailed') // -page.on('requestfinished') // -page.on('response') // -page.on('workercreated') // -page.on('workerdestroyed') // +page.on('close') // Emitted when the page closes. +page.on('console') // Emitted when JavaScript within the page calls one of console API methods. +page.on('dialog') // Emitted when a JavaScript dialog appears, such as alert, prompt, confirm or beforeunload. +page.on('domcontentloaded') // Emitted when the JavaScript DOMContentLoaded event is dispatched. +page.on('error') // Emitted when the page crashes. +page.on('frameattached') // Emitted when a frame is attached. +page.on('framedetached') // Emitted when a frame is detached. +page.on('framenavigated') // Emitted when a frame is navigated to a new url. +page.on('load') // Emitted when the JavaScript load event is dispatched. +page.on('metrics') // Emitted when the JavaScript code makes a call to console.timeStamp. +page.on('pageerror') // Emitted when an uncaught exception happens within the page. +page.on('popup') // Emitted when the page opens a new tab or window. +page.on('request') // Emitted when a page issues a request. +page.on('requestfailed') // Emitted when a request fails, for example by timing out. +page.on('requestfinished') // Emitted when a request finishes successfully. +page.on('response') // Emitted when a response is received. +page.on('workercreated') // Emitted when a dedicated WebWorker is spawned by the page. +page.on('workerdestroyed') // Emitted when a dedicated WebWorker is terminated. -page.accessibility // -page.coverage // -page.keyboard // -page.mouse // -page.touchscreen // -page.tracing // +page.accessibility // returns Accessibility +page.coverage // returns Coverage +page.keyboard // returns Keyboard +page.mouse // returns Mouse +page.touchscreen // returns Touchscreen +page.tracing // returns Tracing -page.$(selector) // -page.$$(selector) // -page.$$eval(selector, pageFunction[, ...args]) // -page.$eval(selector, pageFunction[, ...args]) // -page.$x(expression) // -page.addScriptTag(options) // -page.addStyleTag(options) // -page.authenticate(credentials) // -page.bringToFront() // -page.browser() // -page.browserContext( // -page.click(selector[, options]) // -page.close([options]) // -page.content() // -page.cookies([...urls]) // -page.deleteCookie(...cookies) // -page.emulate(options) // -page.emulateMedia(type) // -page.emulateMediaFeatures(features) // -page.emulateMediaType(type) // -page.emulateTimezone(timezoneId) // -page.evaluate(pageFunction[, ...args]) // -page.evaluateHandle(pageFunction[, ...args]) // -page.evaluateOnNewDocument(pageFunction[, ...args]) // -page.exposeFunction(name, puppeteerFunction) // -page.focus(selector) // -page.frames() // -page.goBack([options]) // -page.goForward([options]) // -page.goto(url[, options]) // -page.hover(selector) // -page.isClosed() // -page.mainFrame() // -page.metrics() // -page.pdf([options]) // -page.queryObjects(prototypeHandle) // -page.reload([options]) // -page.screenshot([options]) // -page.select(selector, ...values) // -page.setBypassCSP(enabled) // -page.setCacheEnabled([enabled]) // -page.setContent(html[, options]) // -page.setCookie(...cookies) // -page.setDefaultNavigationTimeout(timeout) // -page.setDefaultTimeout(timeout) // -page.setExtraHTTPHeaders(headers) // -page.setGeolocation(options) // -page.setJavaScriptEnabled(enabled) // -page.setOfflineMode(enabled) // -page.setRequestInterception(value) // -page.setUserAgent(userAgent) // -page.setViewport(viewport) // -page.tap(selector) // -page.target() // -page.title() // -page.type(selector, text[, options]) // -page.url() // -page.viewport() // -page.waitFor(selectorOrFunctionOrTimeout[, options[, ...args]]) // -page.waitForFileChooser([options]) // -page.waitForFunction(pageFunction[, options[, ...args]]) // -page.waitForNavigation([options]) // -page.waitForRequest(urlOrPredicate[, options]) // -page.waitForResponse(urlOrPredicate[, options]) // -page.waitForSelector(selector[, options]) // -page.waitForXPath(xpath[, options]) // -page.workers() // +page.$(selector) // The method runs document.querySelector within the page. If no element matches the selector, the return value resolves to null. +page.$$(selector) // The method runs document.querySelectorAll within the page. If no elements match the selector, the return value resolves to []. +page.$$eval(selector, pageFunction[, ...args]) // This method runs Array.from(document.querySelectorAll(selector)) within the page and passes it as the first argument to pageFunction. +page.$eval(selector, pageFunction[, ...args]) // This method runs document.querySelector within the page and passes it as the first argument to pageFunction. If there's no element matching selector, the method throws an error. +page.$x(expression) // The method evaluates the XPath expression. +page.addScriptTag(options) // Adds a