mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
2 lines
46 KiB
JavaScript
2 lines
46 KiB
JavaScript
/*! For license information please see ccf9c475.fbb1ecfb.js.LICENSE.txt */
|
|
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[85574],{20602:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>c,contentTitle:()=>d,default:()=>l,frontMatter:()=>i,metadata:()=>a,toc:()=>h});var r=s(85893),n=s(11151);const i={sidebar_label:"Page"},d="Page class",a={id:"api/puppeteer.page",title:"Page class",description:"Page provides methods to interact with a single tab or extension background page in the browser.",source:"@site/../docs/api/puppeteer.page.md",sourceDirName:"api",slug:"/api/puppeteer.page",permalink:"/next/api/puppeteer.page",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{sidebar_label:"Page"},sidebar:"api",previous:{title:"BrowserContext.waitForTarget",permalink:"/next/api/puppeteer.browsercontext.waitfortarget"},next:{title:"Page.$",permalink:"/next/api/puppeteer.page._"}},c={},h=[{value:"Signature:",id:"signature",level:4},{value:"Remarks",id:"remarks",level:2},{value:"Example 1",id:"example-1",level:2},{value:"Example 2",id:"example-2",level:2},{value:"Properties",id:"properties",level:2},{value:"Methods",id:"methods",level:2}];function p(e){const t={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,n.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.h1,{id:"page-class",children:"Page class"}),"\n",(0,r.jsxs)(t.p,{children:["Page provides methods to interact with a single tab or ",(0,r.jsx)(t.a,{href:"https://developer.chrome.com/extensions/background_pages",children:"extension background page"})," in the browser."]}),"\n",(0,r.jsx)(t.admonition,{type:"note",children:(0,r.jsx)(t.p,{children:"One Browser instance might have multiple Page instances."})}),"\n",(0,r.jsx)(t.h4,{id:"signature",children:"Signature:"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-typescript",children:"export declare abstract class Page extends EventEmitter<PageEvents>\n"})}),"\n",(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.strong,{children:"Extends:"})," ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.eventemitter",children:"EventEmitter"}),"<",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.pageevents",children:"PageEvents"}),">"]}),"\n",(0,r.jsx)(t.h2,{id:"remarks",children:"Remarks"}),"\n",(0,r.jsxs)(t.p,{children:["The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the ",(0,r.jsx)(t.code,{children:"Page"})," class."]}),"\n",(0,r.jsx)(t.h2,{id:"example-1",children:"Example 1"}),"\n",(0,r.jsx)(t.p,{children:"This example creates a page, navigates it to a URL, and then saves a screenshot:"}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"import puppeteer from 'puppeteer';\n\n(async () => {\n const browser = await puppeteer.launch();\n const page = await browser.newPage();\n await page.goto('https://example.com');\n await page.screenshot({path: 'screenshot.png'});\n await browser.close();\n})();\n"})}),"\n",(0,r.jsxs)(t.p,{children:["The Page class extends from Puppeteer's ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.eventemitter",children:"EventEmitter"})," class and will emit various events which are documented in the ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.pageevent",children:"PageEvent"})," enum."]}),"\n",(0,r.jsx)(t.h2,{id:"example-2",children:"Example 2"}),"\n",(0,r.jsxs)(t.p,{children:["This example logs a message for a single page ",(0,r.jsx)(t.code,{children:"load"})," event:"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"page.once('load', () => console.log('Page loaded!'));\n"})}),"\n",(0,r.jsxs)(t.p,{children:["To unsubscribe from events use the ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.eventemitter.off",children:"EventEmitter.off()"})," method:"]}),"\n",(0,r.jsx)(t.pre,{children:(0,r.jsx)(t.code,{className:"language-ts",children:"function logRequest(interceptedRequest) {\n console.log('A request was made:', interceptedRequest.url());\n}\npage.on('request', logRequest);\n// Sometime later...\npage.off('request', logRequest);\n"})}),"\n",(0,r.jsx)(t.h2,{id:"properties",children:"Properties"}),"\n",(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Property"})}),(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Modifiers"})}),(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Type"})}),(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Description"})})]})}),(0,r.jsxs)("tbody",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"accessibility",children:"accessibility"})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.code,{children:"readonly"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.accessibility",children:"Accessibility"})})}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["The Accessibility class provides methods for inspecting the browser's accessibility tree. The accessibility tree is used by assistive technology such as ",(0,r.jsx)(t.a,{href:"https://en.wikipedia.org/wiki/Screen_reader",children:"screen readers"})," or ",(0,r.jsx)(t.a,{href:"https://en.wikipedia.org/wiki/Switch_access",children:"switches"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"coverage",children:"coverage"})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.code,{children:"readonly"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.coverage",children:"Coverage"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"The Coverage class provides methods to gather information about parts of JavaScript and CSS that were used by the page."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"keyboard",children:"keyboard"})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.code,{children:"readonly"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.keyboard",children:"Keyboard"})})}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Keyboard provides an api for managing a virtual keyboard. The high level api is ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.keyboard.type",children:"Keyboard.type()"}),", which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"mouse",children:"mouse"})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.code,{children:"readonly"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.mouse",children:"Mouse"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"touchscreen",children:"touchscreen"})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.code,{children:"readonly"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.touchscreen",children:"Touchscreen"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"The Touchscreen class exposes touchscreen events."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"tracing",children:"tracing"})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.code,{children:"readonly"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.tracing",children:"Tracing"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"The Tracing class exposes the tracing audit interface."})})]})]})]}),"\n",(0,r.jsx)(t.h2,{id:"methods",children:"Methods"}),"\n",(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Method"})}),(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Modifiers"})}),(0,r.jsx)("th",{children:(0,r.jsx)(t.p,{children:"Description"})})]})}),(0,r.jsxs)("tbody",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"_",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page._",children:"$(selector)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Runs ",(0,r.jsx)(t.code,{children:"document.querySelector"})," within the page. If no element matches the selector, the return value resolves to ",(0,r.jsx)(t.code,{children:"null"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"__",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.__",children:"$$(selector)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["The method runs ",(0,r.jsx)(t.code,{children:"document.querySelectorAll"})," within the page. If no elements match the selector, the return value resolves to ",(0,r.jsx)(t.code,{children:"[]"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"__eval",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.__eval",children:"$$eval(selector, pageFunction, args)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["This method runs ",(0,r.jsx)(t.code,{children:"Array.from(document.querySelectorAll(selector))"})," within the page and passes the result as the first argument to the ",(0,r.jsx)(t.code,{children:"pageFunction"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"_eval",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page._eval",children:"$eval(selector, pageFunction, args)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["This method runs ",(0,r.jsx)(t.code,{children:"document.querySelector"})," within the page and passes the result as the first argument to the ",(0,r.jsx)(t.code,{children:"pageFunction"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"addscripttag",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.addscripttag",children:"addScriptTag(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Adds a ",(0,r.jsx)(t.code,{children:"<script>"})," tag into the page with the desired URL or content."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"addstyletag",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.addstyletag",children:"addStyleTag(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsxs)(t.p,{children:["Adds a ",(0,r.jsx)(t.code,{children:'<link rel="stylesheet">'})," tag into the page with the desired URL or a ",(0,r.jsx)(t.code,{children:'<style type="text/css">'})," tag with the content."]}),(0,r.jsxs)(t.p,{children:["Shortcut for ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.frame.addstyletag_1",children:"page.mainFrame().addStyleTag(options)"}),"."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"addstyletag",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.addstyletag_1",children:"addStyleTag(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"authenticate",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.authenticate",children:"authenticate(credentials)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Provide credentials for ",(0,r.jsx)(t.code,{children:"HTTP authentication"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"bringtofront",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.bringtofront",children:"bringToFront()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Brings page to front (activates tab)."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"browser",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.browser",children:"browser()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Get the browser the page belongs to."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"browsercontext",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.browsercontext",children:"browserContext()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Get the browser context that the page belongs to."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"click",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.click",children:"click(selector, options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["This method fetches an element with ",(0,r.jsx)(t.code,{children:"selector"}),", scrolls it into view if needed, and then uses ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page#mouse",children:"Page.mouse"})," to click in the center of the element. If there's no element matching ",(0,r.jsx)(t.code,{children:"selector"}),", the method throws an error."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"close",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.close",children:"close(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"content",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.content",children:"content()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"The full HTML contents of the page, including the DOCTYPE."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"cookies",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.cookies",children:"cookies(urls)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"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."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"createcdpsession",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.createcdpsession",children:"createCDPSession()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Creates a Chrome Devtools Protocol session attached to the page."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"createpdfstream",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.createpdfstream",children:"createPDFStream(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Generates a PDF of the page with the ",(0,r.jsx)(t.code,{children:"print"})," CSS media type."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"deletecookie",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.deletecookie",children:"deleteCookie(cookies)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"emulate",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.emulate",children:"emulate(device)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:"Emulates a given device's metrics and user agent."}),(0,r.jsxs)(t.p,{children:["To aid emulation, Puppeteer provides a list of known devices that can be via ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.knowndevices",children:"KnownDevices"}),"."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"emulatecputhrottling",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.emulatecputhrottling",children:"emulateCPUThrottling(factor)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Enables CPU throttling to emulate slow CPUs."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"emulateidlestate",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.emulateidlestate",children:"emulateIdleState(overrides)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Emulates the idle state. If no arguments set, clears idle state emulation."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"emulatemediafeatures",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.emulatemediafeatures",children:"emulateMediaFeatures(features)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"emulatemediatype",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.emulatemediatype",children:"emulateMediaType(type)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"emulatenetworkconditions",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.emulatenetworkconditions",children:"emulateNetworkConditions(networkConditions)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsxs)(t.p,{children:["This does not affect WebSockets and WebRTC PeerConnections (see ",(0,r.jsx)(t.a,{href:"https://crbug.com/563644",children:"https://crbug.com/563644"}),"). To set the page offline, you can use ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setofflinemode",children:"Page.setOfflineMode()"}),"."]}),(0,r.jsxs)(t.p,{children:["A list of predefined network conditions can be used by importing ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.predefinednetworkconditions",children:"PredefinedNetworkConditions"}),"."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"emulatetimezone",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.emulatetimezone",children:"emulateTimezone(timezoneId)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"emulatevisiondeficiency",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.emulatevisiondeficiency",children:"emulateVisionDeficiency(type)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Simulates the given vision deficiency on the page."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"evaluate",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.evaluate",children:"evaluate(pageFunction, args)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:"Evaluates a function in the page's context and returns the result."}),(0,r.jsxs)(t.p,{children:["If the function passed to ",(0,r.jsx)(t.code,{children:"page.evaluate"})," returns a Promise, the function will wait for the promise to resolve and return its value."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"evaluatehandle",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.evaluatehandle",children:"evaluateHandle(pageFunction, args)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"evaluateonnewdocument",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.evaluateonnewdocument",children:"evaluateOnNewDocument(pageFunction, args)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:"Adds a function which would be invoked in one of the following scenarios:"}),(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:"whenever the page is navigated"}),"\n"]}),"\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:"whenever the child frame is attached or navigated. In this case, the function is invoked in the context of the newly attached frame."}),"\n"]}),"\n"]}),(0,r.jsxs)(t.p,{children:["The function is invoked after the document was created but before any of its scripts were run. This is useful to amend the JavaScript environment, e.g. to seed ",(0,r.jsx)(t.code,{children:"Math.random"}),"."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"exposefunction",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.exposefunction",children:"exposeFunction(name, pptrFunction)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsxs)(t.p,{children:["The method adds a function called ",(0,r.jsx)(t.code,{children:"name"})," on the page's ",(0,r.jsx)(t.code,{children:"window"})," object. When called, the function executes ",(0,r.jsx)(t.code,{children:"puppeteerFunction"})," in node.js and returns a ",(0,r.jsx)(t.code,{children:"Promise"})," which resolves to the return value of ",(0,r.jsx)(t.code,{children:"puppeteerFunction"}),"."]}),(0,r.jsxs)(t.p,{children:["If the puppeteerFunction returns a ",(0,r.jsx)(t.code,{children:"Promise"}),", it will be awaited."]}),(0,r.jsx)(t.admonition,{type:"note",children:(0,r.jsxs)(t.p,{children:["Functions installed via ",(0,r.jsx)(t.code,{children:"page.exposeFunction"})," survive navigations."]})})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"focus",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.focus",children:"focus(selector)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["This method fetches an element with ",(0,r.jsx)(t.code,{children:"selector"})," and focuses it. If there's no element matching ",(0,r.jsx)(t.code,{children:"selector"}),", the method throws an error."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"frames",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.frames",children:"frames()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"An array of all frames attached to the page."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"getdefaulttimeout",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.getdefaulttimeout",children:"getDefaultTimeout()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Maximum time in milliseconds."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"goback",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.goback",children:"goBack(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"This method navigate to the previous page in history."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"goforward",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.goforward",children:"goForward(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"This method navigate to the next page in history."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"goto",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.goto",children:"goto(url, options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Navigates the page to the given ",(0,r.jsx)(t.code,{children:"url"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"hover",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.hover",children:"hover(selector)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["This method fetches an element with ",(0,r.jsx)(t.code,{children:"selector"}),", scrolls it into view if needed, and then uses ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page#mouse",children:"Page.mouse"})," to hover over the center of the element. If there's no element matching ",(0,r.jsx)(t.code,{children:"selector"}),", the method throws an error."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"isclosed",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.isclosed",children:"isClosed()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Indicates that the page has been closed."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"isdraginterceptionenabled",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.isdraginterceptionenabled",children:"isDragInterceptionEnabled()"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.code,{children:"deprecated"})})}),(0,r.jsxs)("td",{children:[(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"true"})," if drag events are being intercepted, ",(0,r.jsx)(t.code,{children:"false"})," otherwise."]}),(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"Deprecated:"})}),(0,r.jsxs)(t.p,{children:["We no longer support intercepting drag payloads. Use the new drag APIs found on ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.elementhandle",children:"ElementHandle"})," to drag (or just use the ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page#mouse",children:"Page.mouse"}),")."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"isjavascriptenabled",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.isjavascriptenabled",children:"isJavaScriptEnabled()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"true"})," if the page has JavaScript enabled, ",(0,r.jsx)(t.code,{children:"false"})," otherwise."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"isserviceworkerbypassed",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.isserviceworkerbypassed",children:"isServiceWorkerBypassed()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"true"})," if the service worker are being bypassed, ",(0,r.jsx)(t.code,{children:"false"})," otherwise."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"locator",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.locator",children:"locator(selector)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Creates a locator for the provided selector. See ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.locator",children:"Locator"})," for details and supported actions."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"locator",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.locator_1",children:"locator(func)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Creates a locator for the provided function. See ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.locator",children:"Locator"})," for details and supported actions."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"mainframe",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.mainframe",children:"mainFrame()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"The page's main frame."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"metrics",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.metrics",children:"metrics()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Object containing metrics as key/value pairs."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"pdf",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.pdf",children:"pdf(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Generates a PDF of the page with the ",(0,r.jsx)(t.code,{children:"print"})," CSS media type."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"queryobjects",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.queryobjects",children:"queryObjects(prototypeHandle)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"This method iterates the JavaScript heap and finds all objects with the given prototype."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"reload",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.reload",children:"reload(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Reloads the page."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"removeexposedfunction",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.removeexposedfunction",children:"removeExposedFunction(name)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["The method removes a previously added function via $",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.exposefunction",children:"Page.exposeFunction()"})," called ",(0,r.jsx)(t.code,{children:"name"})," from the page's ",(0,r.jsx)(t.code,{children:"window"})," object."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"removescripttoevaluateonnewdocument",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.removescripttoevaluateonnewdocument",children:"removeScriptToEvaluateOnNewDocument(identifier)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Removes script that injected into page by Page.evaluateOnNewDocument."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"screencast",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.screencast",children:"screencast(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Captures a screencast of this ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page",children:"page"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"screenshot",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.screenshot",children:"screenshot(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Captures a screenshot of this ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page",children:"page"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"screenshot",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.screenshot_1",children:"screenshot(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"select",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.select",children:"select(selector, values)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Triggers a ",(0,r.jsx)(t.code,{children:"change"})," and ",(0,r.jsx)(t.code,{children:"input"})," event once all the provided options have been selected. If there's no ",(0,r.jsx)(t.code,{children:"<select>"})," element matching ",(0,r.jsx)(t.code,{children:"selector"}),", the method throws an error."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setbypasscsp",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setbypasscsp",children:"setBypassCSP(enabled)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Toggles bypassing page's Content-Security-Policy."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setbypassserviceworker",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setbypassserviceworker",children:"setBypassServiceWorker(bypass)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Toggles ignoring of service worker for each request."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setcacheenabled",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setcacheenabled",children:"setCacheEnabled(enabled)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Toggles ignoring cache for each request based on the enabled state. By default, caching is enabled."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setcontent",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setcontent",children:"setContent(html, options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Set the content of the page."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setcookie",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setcookie",children:"setCookie(cookies)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setdefaultnavigationtimeout",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setdefaultnavigationtimeout",children:"setDefaultNavigationTimeout(timeout)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:"This setting will change the default maximum navigation time for the following methods and related shortcuts:"}),(0,r.jsxs)(t.ul,{children:["\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.goback",children:"page.goBack(options)"})}),"\n"]}),"\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.goforward",children:"page.goForward(options)"})}),"\n"]}),"\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.goto",children:"page.goto(url,options)"})}),"\n"]}),"\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.reload",children:"page.reload(options)"})}),"\n"]}),"\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setcontent",children:"page.setContent(html,options)"})}),"\n"]}),"\n",(0,r.jsxs)(t.li,{children:["\n",(0,r.jsx)(t.p,{children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.waitfornavigation",children:"page.waitForNavigation(options)"})}),"\n"]}),"\n"]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setdefaulttimeout",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setdefaulttimeout",children:"setDefaultTimeout(timeout)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setdraginterception",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setdraginterception",children:"setDragInterception(enabled)"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.code,{children:"deprecated"})})}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"Deprecated:"})}),(0,r.jsxs)(t.p,{children:["We no longer support intercepting drag payloads. Use the new drag APIs found on ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.elementhandle",children:"ElementHandle"})," to drag (or just use the ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page#mouse",children:"Page.mouse"}),")."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setextrahttpheaders",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setextrahttpheaders",children:"setExtraHTTPHeaders(headers)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:"The extra HTTP headers will be sent with every request the page initiates."}),(0,r.jsx)(t.admonition,{type:"tip",children:(0,r.jsx)(t.p,{children:"All HTTP header names are lowercased. (HTTP headers are case-insensitive, so this shouldn\u2019t impact your server code.)"})}),(0,r.jsx)(t.admonition,{type:"note",children:(0,r.jsx)(t.p,{children:"page.setExtraHTTPHeaders does not guarantee the order of headers in the outgoing requests."})})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setgeolocation",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setgeolocation",children:"setGeolocation(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Sets the page's geolocation."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setjavascriptenabled",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setjavascriptenabled",children:"setJavaScriptEnabled(enabled)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setofflinemode",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setofflinemode",children:"setOfflineMode(enabled)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:"Sets the network connection to offline."}),(0,r.jsxs)(t.p,{children:["It does not change the parameters used in ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.emulatenetworkconditions",children:"Page.emulateNetworkConditions()"})]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setrequestinterception",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setrequestinterception",children:"setRequestInterception(value)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsxs)(t.p,{children:["Activating request interception enables ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.httprequest.abort",children:"HTTPRequest.abort()"}),", ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.httprequest.continue",children:"HTTPRequest.continue()"})," and ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.httprequest.respond",children:"HTTPRequest.respond()"})," methods. This provides the capability to modify network requests that are made by a page."]}),(0,r.jsx)(t.p,{children:"Once request interception is enabled, every request will stall unless it's continued, responded or aborted; or completed using the browser cache."}),(0,r.jsxs)(t.p,{children:["See the ",(0,r.jsx)(t.a,{href:"https://pptr.dev/next/guides/request-interception",children:"Request interception guide"})," for more details."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setuseragent",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setuseragent",children:"setUserAgent(userAgent, userAgentMetadata)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"setviewport",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setviewport",children:"setViewport(viewport)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.code,{children:"page.setViewport"})," will resize the page. A lot of websites don't expect phones to change size, so you should set the viewport before navigating to the page."]}),(0,r.jsx)(t.p,{children:"In the case of multiple pages in a single browser, each page can have its own viewport size."})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"tap",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.tap",children:"tap(selector)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["This method fetches an element with ",(0,r.jsx)(t.code,{children:"selector"}),", scrolls it into view if needed, and then uses ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page#touchscreen",children:"Page.touchscreen"})," to tap in the center of the element. If there's no element matching ",(0,r.jsx)(t.code,{children:"selector"}),", the method throws an error."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"target",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.target",children:"target()"})})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:(0,r.jsx)(t.code,{children:"deprecated"})})}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:"A target this page was created from."}),(0,r.jsx)(t.p,{children:(0,r.jsx)(t.strong,{children:"Deprecated:"})}),(0,r.jsxs)(t.p,{children:["Use ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.createcdpsession",children:"Page.createCDPSession()"})," directly."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"title",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.title",children:"title()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"The page's title"})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"type",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.type",children:"type(selector, text, options)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsxs)(t.p,{children:["Sends a ",(0,r.jsx)(t.code,{children:"keydown"}),", ",(0,r.jsx)(t.code,{children:"keypress/input"}),", and ",(0,r.jsx)(t.code,{children:"keyup"})," event for each character in the text."]}),(0,r.jsxs)(t.p,{children:["To press a special key, like ",(0,r.jsx)(t.code,{children:"Control"})," or ",(0,r.jsx)(t.code,{children:"ArrowDown"}),", use ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.keyboard.press",children:"Keyboard.press()"}),"."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"url",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.url",children:"url()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"The page's URL."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"viewport",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.viewport",children:"viewport()"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:"Returns the current page viewport settings without checking the actual page viewport."}),(0,r.jsxs)(t.p,{children:["This is either the viewport set with the previous ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.setviewport",children:"Page.setViewport()"})," call or the default viewport set via ",(0,r.jsx)(t.a,{href:"/next/api/puppeteer.browserconnectoptions#defaultviewport",children:"BrowserConnectOptions.defaultViewport"}),"."]})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"waitfordeviceprompt",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.waitfordeviceprompt",children:"waitForDevicePrompt(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:"This method is typically coupled with an action that triggers a device request from an api such as WebBluetooth."}),(0,r.jsx)(t.admonition,{type:"caution",children:(0,r.jsx)(t.p,{children:"This must be called before the device request is made. It will not return a currently active device prompt."})})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"waitforfilechooser",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.waitforfilechooser",children:"waitForFileChooser(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsxs)("td",{children:[(0,r.jsx)(t.p,{children:"This method is typically coupled with an action that triggers file choosing."}),(0,r.jsx)(t.admonition,{type:"caution",children:(0,r.jsx)(t.p,{children:"This must be called before the file chooser is launched. It will not return a currently active file chooser."})})]})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"waitforframe",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.waitforframe",children:"waitForFrame(urlOrPredicate, options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Waits for a frame matching the given conditions to appear."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"waitforfunction",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.waitforfunction",children:"waitForFunction(pageFunction, options, args)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Waits for the provided function, ",(0,r.jsx)(t.code,{children:"pageFunction"}),", to return a truthy value when evaluated in the page's context."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"waitfornavigation",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.waitfornavigation",children:"waitForNavigation(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Waits for the page to navigate to a new URL or to reload. It is useful when you run code that will indirectly cause the page to navigate."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"waitfornetworkidle",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.waitfornetworkidle",children:"waitForNetworkIdle(options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Waits for the network to be idle."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"waitforrequest",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.waitforrequest",children:"waitForRequest(urlOrPredicate, options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"waitforresponse",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.waitforresponse",children:"waitForResponse(urlOrPredicate, options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"waitforselector",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.waitforselector",children:"waitForSelector(selector, options)"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["Wait for the ",(0,r.jsx)(t.code,{children:"selector"})," to appear in page. If at the moment of calling the method the ",(0,r.jsx)(t.code,{children:"selector"})," already exists, the method will return immediately. If the ",(0,r.jsx)(t.code,{children:"selector"})," doesn't appear after the ",(0,r.jsx)(t.code,{children:"timeout"})," milliseconds of waiting, the function will throw."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)("span",{id:"workers",children:(0,r.jsx)(t.a,{href:"/next/api/puppeteer.page.workers",children:"workers()"})})}),(0,r.jsx)("td",{}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:["All of the dedicated ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API",children:"WebWorkers"})," associated with the page."]})})]})]})]})]})}function l(e={}){const{wrapper:t}={...(0,n.a)(),...e.components};return t?(0,r.jsx)(t,{...e,children:(0,r.jsx)(p,{...e})}):p(e)}},75251:(e,t,s)=>{var r=s(67294),n=Symbol.for("react.element"),i=Symbol.for("react.fragment"),d=Object.prototype.hasOwnProperty,a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function h(e,t,s){var r,i={},h=null,p=null;for(r in void 0!==s&&(h=""+s),void 0!==t.key&&(h=""+t.key),void 0!==t.ref&&(p=t.ref),t)d.call(t,r)&&!c.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===i[r]&&(i[r]=t[r]);return{$$typeof:n,type:e,key:h,ref:p,props:i,_owner:a.current}}t.Fragment=i,t.jsx=h,t.jsxs=h},85893:(e,t,s)=>{e.exports=s(75251)},11151:(e,t,s)=>{s.d(t,{Z:()=>a,a:()=>d});var r=s(67294);const n={},i=r.createContext(n);function d(e){const t=r.useContext(i);return r.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:d(e.components),r.createElement(i.Provider,{value:t},e.children)}}}]); |