puppeteer/assets/js/0034c797.b1093b83.js
release-please[bot] d321f9557a deploy: 8c0ac61260
2023-12-06 08:09:55 +00:00

2 lines
15 KiB
JavaScript

/*! For license information please see 0034c797.b1093b83.js.LICENSE.txt */
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[48651],{4719:(e,r,n)=>{n.r(r),n.d(r,{assets:()=>d,contentTitle:()=>t,default:()=>h,frontMatter:()=>l,metadata:()=>o,toc:()=>c});var i=n(85893),s=n(11151);const l={},t="Experimental WebDriver BiDi Support",o={id:"webdriver-bidi",title:"Experimental WebDriver BiDi Support",description:"WebDriver BiDi is a new cross-browser",source:"@site/versioned_docs/version-21.6.0/webdriver-bidi.md",sourceDirName:".",slug:"/webdriver-bidi",permalink:"/webdriver-bidi",draft:!1,unlisted:!1,tags:[],version:"21.6.0",frontMatter:{},sidebar:"docs",previous:{title:"Puppeteer Angular Schematic",permalink:"/integrations/ng-schematics"},next:{title:"Chromium Support",permalink:"/chromium-support"}},d={},c=[{value:"Automate with Chrome and Firefox",id:"automate-with-chrome-and-firefox",level:2},{value:"Puppeteer features supported over WebDriver BiDi",id:"puppeteer-features-supported-over-webdriver-bidi",level:2},{value:"Puppeteer features not yet supported over WebDriver BiDi",id:"puppeteer-features-not-yet-supported-over-webdriver-bidi",level:2}];function a(e){const r={a:"a",code:"code",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.h1,{id:"experimental-webdriver-bidi-support",children:"Experimental WebDriver BiDi Support"}),"\n",(0,i.jsxs)(r.p,{children:[(0,i.jsx)(r.a,{href:"https://w3c.github.io/webdriver-bidi/",children:"WebDriver BiDi"})," is a new cross-browser\nautomation protocol that adds browser-driven events to WebDriver. Here are the\nresources if you want to learn more about WebDriver BiDi:"]}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:(0,i.jsx)(r.a,{href:"https://developer.chrome.com/articles/webdriver-bidi/",children:"WebDriver BiDi - The future of cross-browser automation"})}),"\n",(0,i.jsx)(r.li,{children:(0,i.jsx)(r.a,{href:"https://developer.chrome.com/blog/webdriver-bidi-2023/",children:"WebDriver BiDi: 2023 status update"})}),"\n"]}),"\n",(0,i.jsx)(r.h2,{id:"automate-with-chrome-and-firefox",children:"Automate with Chrome and Firefox"}),"\n",(0,i.jsxs)(r.p,{children:["Firefox support has almost reaching feature parity with the previous CDP-based\nimplementation. To see which features are fully supported with WebDriver BiDi we\nused the ",(0,i.jsx)(r.a,{href:"https://puppeteer.github.io/ispuppeteerwebdriverbidiready/",children:"Puppeteer test suite"}),". Currently,\nwe still have fewer than\n",(0,i.jsx)(r.a,{href:"https://puppeteer.github.io/ispuppeteerwebdriverbidiready/firefox-delta.json",children:"60"}),"\ntests that are failing with Firefox and WebDriver BiDi compared to the previous\nCDP implementation in Firefox but we also have more than\n",(0,i.jsx)(r.a,{href:"https://puppeteer.github.io/ispuppeteerwebdriverbidiready/firefox-delta.json",children:"82"}),"\nnew tests that work with WebDriver BiDi and that didn't work with CDP."]}),"\n",(0,i.jsx)(r.p,{children:"For Chrome, around 68% of the tests are currently passing with WebDriver BiDi so\nthe CDP-based implementation remains more powerful. Some of the Puppeteer\nfunctionality is relying on CDP even with WebDriver BiDi enabled. Therefore, the\ntest pass rate is currently higher than that one of Firefox."}),"\n",(0,i.jsx)(r.p,{children:"Example of launching Firefox with WebDriver BiDi:"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-ts",children:"import puppeteer from 'puppeteer';\n\nconst browser = await puppeteer.launch({\n product: 'firefox',\n protocol: 'webDriverBiDi',\n});\nconst page = await browser.newPage();\n...\nawait browser.close();\n"})}),"\n",(0,i.jsx)(r.p,{children:"Example of launching Chrome with WebDriver BiDi:"}),"\n",(0,i.jsx)(r.pre,{children:(0,i.jsx)(r.code,{className:"language-ts",children:"import puppeteer from 'puppeteer';\n\nconst browser = await puppeteer.launch({\n product: 'chrome',\n protocol: 'webDriverBiDi',\n});\nconst page = await browser.newPage();\n...\nawait browser.close();\n"})}),"\n",(0,i.jsx)(r.h2,{id:"puppeteer-features-supported-over-webdriver-bidi",children:"Puppeteer features supported over WebDriver BiDi"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"Browser and page automation"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"Browser.close"}),"\n",(0,i.jsxs)(r.li,{children:["Frame.goto() (except ",(0,i.jsx)(r.code,{children:"referer"})," and ",(0,i.jsx)(r.code,{children:"referrerPolicy"}),")"]}),"\n",(0,i.jsx)(r.li,{children:"Page.bringToFront"}),"\n",(0,i.jsx)(r.li,{children:"Page.goBack()"}),"\n",(0,i.jsx)(r.li,{children:"Page.goForward()"}),"\n",(0,i.jsxs)(r.li,{children:["Page.goto (except ",(0,i.jsx)(r.code,{children:"referer"})," and ",(0,i.jsx)(r.code,{children:"referrerPolicy"}),")"]}),"\n",(0,i.jsxs)(r.li,{children:["Page.reload (except for ",(0,i.jsx)(r.code,{children:"ignoreCache"})," parameter)"]}),"\n",(0,i.jsxs)(r.li,{children:["Page.setViewport (",(0,i.jsx)(r.code,{children:"width"}),", ",(0,i.jsx)(r.code,{children:"height"}),", ",(0,i.jsx)(r.code,{children:"deviceScaleFactor"})," only)"]}),"\n",(0,i.jsx)(r.li,{children:"Puppeteer.launch"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsxs)(r.p,{children:[(0,i.jsx)(r.a,{href:"https://pptr.dev/guides/evaluate-javascript",children:"Script evaluation"}),":"]}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"JSHandle.evaluate"}),"\n",(0,i.jsx)(r.li,{children:"JSHandle.evaluateHandle"}),"\n",(0,i.jsx)(r.li,{children:"Page.evaluate"}),"\n",(0,i.jsx)(r.li,{children:"Page.exposeFunction"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsxs)(r.p,{children:[(0,i.jsx)(r.a,{href:"https://pptr.dev/guides/query-selectors",children:"Selectors"})," and ",(0,i.jsx)(r.a,{href:"https://pptr.dev/guides/locators",children:"locators"})," except for ARIA:"]}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"Page.$ (ARIA selectors supported in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.$$ (ARIA selectors supported in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.$$eval (ARIA selectors supported in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.$eval (ARIA selectors supported in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.waitForSelector (ARIA selectors supported in Chrome)"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"Input"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"ElementHandle.click"}),"\n",(0,i.jsx)(r.li,{children:"Keyboard.down"}),"\n",(0,i.jsx)(r.li,{children:"Keyboard.press"}),"\n",(0,i.jsx)(r.li,{children:"Keyboard.sendCharacter"}),"\n",(0,i.jsx)(r.li,{children:"Keyboard.type"}),"\n",(0,i.jsx)(r.li,{children:"Keyboard.up"}),"\n",(0,i.jsx)(r.li,{children:"Mouse events (except for dedicated drag'n'drop API methods)"}),"\n",(0,i.jsx)(r.li,{children:"Page.tap"}),"\n",(0,i.jsx)(r.li,{children:"TouchScreen.*"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"JavaScript dialog interception"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"page.on('dialog')"}),"\n",(0,i.jsx)(r.li,{children:"Dialog.*"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"Screenshots (not all parameters are supported)"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:["Page.screenshot (supported parameters ",(0,i.jsx)(r.code,{children:"clip"}),", ",(0,i.jsx)(r.code,{children:"encoding"}),", ",(0,i.jsx)(r.code,{children:"fullPage"}),")"]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"PDF generation (not all parameters are supported)"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:["Page.pdf (only ",(0,i.jsx)(r.code,{children:"format"}),", ",(0,i.jsx)(r.code,{children:"height"}),", ",(0,i.jsx)(r.code,{children:"landscape"}),", ",(0,i.jsx)(r.code,{children:"margin"}),", ",(0,i.jsx)(r.code,{children:"pageRanges"}),", ",(0,i.jsx)(r.code,{children:"printBackground"}),", ",(0,i.jsx)(r.code,{children:"scale"}),", ",(0,i.jsx)(r.code,{children:"width"})," are supported)"]}),"\n",(0,i.jsxs)(r.li,{children:["Page.createPDFStream (only ",(0,i.jsx)(r.code,{children:"format"}),", ",(0,i.jsx)(r.code,{children:"height"}),", ",(0,i.jsx)(r.code,{children:"landscape"}),", ",(0,i.jsx)(r.code,{children:"margin"}),", ",(0,i.jsx)(r.code,{children:"pageRanges"}),", ",(0,i.jsx)(r.code,{children:"printBackground"}),", ",(0,i.jsx)(r.code,{children:"scale"}),", ",(0,i.jsx)(r.code,{children:"width"})," are supported)"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(r.h2,{id:"puppeteer-features-not-yet-supported-over-webdriver-bidi",children:"Puppeteer features not yet supported over WebDriver BiDi"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:(0,i.jsx)(r.a,{href:"https://pptr.dev/guides/request-interception",children:"Request interception"})}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"HTTPRequest.abort()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPRequest.abortErrorReason()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPRequest.client()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPRequest.continue()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPRequest.continueRequestOverrides()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPRequest.failure()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPRequest.finalizeInterceptions()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPRequest.interceptResolutionState()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPRequest.isInterceptResolutionHandled()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPRequest.respond()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPRequest.responseForRequest()"}),"\n",(0,i.jsx)(r.li,{children:"Page.setRequestInterception()"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"Permissions"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"BrowserContext.clearPermissionOverrides()"}),"\n",(0,i.jsx)(r.li,{children:"BrowserContext.overridePermissions()"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"Various emulations (most are supported with Chrome)"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"Page.emulate() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.emulateCPUThrottling() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.emulateIdleState() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.emulateMediaFeatures() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.emulateMediaType() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.emulateTimezone() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.emulateVisionDeficiency() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.setBypassCSP() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.setCacheEnabled() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.setGeolocation() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.setJavaScriptEnabled() (supported only in Chrome)"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"CDP-specific features"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"Page.createCDPSession() (supported only in Chrome)"}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"Tracing (supported only in Chrome)"}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"Coverage (supported only in Chrome)"}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"Accessibility (supported only in Chrome)"}),"\n"]}),"\n",(0,i.jsxs)(r.li,{children:["\n",(0,i.jsx)(r.p,{children:"Other methods:"}),"\n",(0,i.jsxs)(r.ul,{children:["\n",(0,i.jsx)(r.li,{children:"Browser.userAgent()"}),"\n",(0,i.jsx)(r.li,{children:"ElementHandle.uploadFile()"}),"\n",(0,i.jsx)(r.li,{children:"Frame.isOOPFrame()"}),"\n",(0,i.jsx)(r.li,{children:"Frame.waitForDevicePrompt()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPResponse.buffer()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPResponse.fromServiceWorker()"}),"\n",(0,i.jsx)(r.li,{children:"HTTPResponse.securityDetails()"}),"\n",(0,i.jsx)(r.li,{children:"Input.drag()"}),"\n",(0,i.jsx)(r.li,{children:"Input.dragAndDrop()"}),"\n",(0,i.jsx)(r.li,{children:"Input.dragOver()"}),"\n",(0,i.jsx)(r.li,{children:"Input.drop()"}),"\n",(0,i.jsx)(r.li,{children:"Page.authenticate()"}),"\n",(0,i.jsx)(r.li,{children:"Page.cookies()"}),"\n",(0,i.jsx)(r.li,{children:"Page.deleteCookie()"}),"\n",(0,i.jsx)(r.li,{children:"Page.emulateNetworkConditions()"}),"\n",(0,i.jsx)(r.li,{children:"Page.isDragInterceptionEnabled()"}),"\n",(0,i.jsx)(r.li,{children:"Page.isJavaScriptEnabled() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.isServiceWorkerBypassed()"}),"\n",(0,i.jsx)(r.li,{children:"Page.metrics()"}),"\n",(0,i.jsx)(r.li,{children:"Page.queryObjects() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.screencast() (supported only in Chrome)"}),"\n",(0,i.jsx)(r.li,{children:"Page.setBypassServiceWorker()"}),"\n",(0,i.jsx)(r.li,{children:"Page.setCookie()"}),"\n",(0,i.jsx)(r.li,{children:"Page.setDragInterception()"}),"\n",(0,i.jsx)(r.li,{children:"Page.setExtraHTTPHeaders()"}),"\n",(0,i.jsx)(r.li,{children:"Page.setOfflineMode()"}),"\n",(0,i.jsx)(r.li,{children:"Page.setUserAgent()"}),"\n",(0,i.jsx)(r.li,{children:"Page.waitForDevicePrompt()"}),"\n",(0,i.jsx)(r.li,{children:"Page.waitForFileChooser()"}),"\n",(0,i.jsx)(r.li,{children:"Page.workers()"}),"\n",(0,i.jsx)(r.li,{children:"PageEvent.popup"}),"\n",(0,i.jsx)(r.li,{children:"PageEvent.WorkerCreated"}),"\n",(0,i.jsx)(r.li,{children:"PageEvent.WorkerDestroyed"}),"\n",(0,i.jsx)(r.li,{children:"Target.opener()"}),"\n"]}),"\n"]}),"\n"]})]})}function h(e={}){const{wrapper:r}={...(0,s.a)(),...e.components};return r?(0,i.jsx)(r,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}},75251:(e,r,n)=>{var i=n(67294),s=Symbol.for("react.element"),l=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,o=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function c(e,r,n){var i,l={},c=null,a=null;for(i in void 0!==n&&(c=""+n),void 0!==r.key&&(c=""+r.key),void 0!==r.ref&&(a=r.ref),r)t.call(r,i)&&!d.hasOwnProperty(i)&&(l[i]=r[i]);if(e&&e.defaultProps)for(i in r=e.defaultProps)void 0===l[i]&&(l[i]=r[i]);return{$$typeof:s,type:e,key:c,ref:a,props:l,_owner:o.current}}r.Fragment=l,r.jsx=c,r.jsxs=c},85893:(e,r,n)=>{e.exports=n(75251)},11151:(e,r,n)=>{n.d(r,{Z:()=>o,a:()=>t});var i=n(67294);const s={},l=i.createContext(s);function t(e){const r=i.useContext(l);return i.useMemo((function(){return"function"==typeof e?e(r):{...r,...e}}),[r,e])}function o(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:t(e.components),i.createElement(l.Provider,{value:r},e.children)}}}]);