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