1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-11-18 11:05:16 +00:00

feat(puppeteer): add page functions

This commit is contained in:
Julien Le Coupanec 2020-03-17 22:07:34 +01:00
parent 7937ffea53
commit 1716f3f575

View File

@ -117,55 +117,54 @@ 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.$(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 <script> tag into the page with the desired url or content.
page.addStyleTag(options) // Adds a <link rel="stylesheet"> tag into the page with the desired url or a <style type="text/css"> tag with the content.
page.authenticate(credentials) // Provide credentials for HTTP authentication.
page.bringToFront() // Brings page to front (activates tab).
page.browser() // Get the browser the page belongs to.
page.browserContext( // Get the browser context that the page belongs to.
page.click(selector[, options]) // This method fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to click in the center of the element. If there's no element matching selector, the method throws an error.
page.close([options]) // Close the page
page.content() // Gets the full HTML contents of the page, including the doctype.
page.cookies([...urls]) // If no URLs are specified, this method returns cookies for the current page URL. If URLs are specified, only cookies for those URLs are returned.
page.deleteCookie(...cookies) // Delete a cookie
page.emulate(options) // Emulates given device metrics and user agent.
page.emulateMediaFeatures(features) // Emulates CSS media features on the page.
page.emulateMediaType(type) // Changes the CSS media type of the page.
page.emulateTimezone(timezoneId) // Changes the timezone of the page.
page.evaluate(pageFunction[, ...args]) // Evaluate the page.
page.evaluateHandle(pageFunction[, ...args]) // Evaluate the page and return returns in-page object (JSHandle).
page.evaluateOnNewDocument(pageFunction[, ...args]) //
page.exposeFunction(name, puppeteerFunction) //
page.focus(selector) //