|
|
|
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[79886],{23032:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>a,contentTitle:()=>o,default:()=>p,frontMatter:()=>i,metadata:()=>c,toc:()=>d});var t=n(85893),r=n(11151);const i={sidebar_label:"CDPSession"},o="CDPSession class",c={id:"api/puppeteer.cdpsession",title:"CDPSession class",description:"The CDPSession instances are used to talk raw Chrome Devtools Protocol.",source:"@site/../docs/api/puppeteer.cdpsession.md",sourceDirName:"api",slug:"/api/puppeteer.cdpsession",permalink:"/next/api/puppeteer.cdpsession",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{sidebar_label:"CDPSession"},sidebar:"api",previous:{title:"Target.worker",permalink:"/next/api/puppeteer.target.worker"},next:{title:"CDPSession.connection",permalink:"/next/api/puppeteer.cdpsession.connection"}},a={},d=[{value:"Signature:",id:"signature",level:4},{value:"Remarks",id:"remarks",level:2},{value:"Example",id:"example",level:2},{value:"Methods",id:"methods",level:2}];function l(e){const s={a:"a",code:"code",h1:"h1",h2:"h2",h4:"h4",p:"p",pre:"pre",strong:"strong",...(0,r.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.h1,{id:"cdpsession-class",children:"CDPSession class"}),"\n",(0,t.jsxs)(s.p,{children:["The ",(0,t.jsx)(s.code,{children:"CDPSession"})," instances are used to talk raw Chrome Devtools Protocol."]}),"\n",(0,t.jsx)(s.h4,{id:"signature",children:"Signature:"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-typescript",children:"export declare abstract class CDPSession extends EventEmitter<CDPSessionEvents>\n"})}),"\n",(0,t.jsxs)(s.p,{children:[(0,t.jsx)(s.strong,{children:"Extends:"})," ",(0,t.jsx)(s.a,{href:"/next/api/puppeteer.eventemitter",children:"EventEmitter"}),"<",(0,t.jsx)(s.a,{href:"/next/api/puppeteer.cdpsessionevents",children:"CDPSessionEvents"}),">"]}),"\n",(0,t.jsx)(s.h2,{id:"remarks",children:"Remarks"}),"\n",(0,t.jsxs)(s.p,{children:["Protocol methods can be called with ",(0,t.jsx)(s.a,{href:"/next/api/puppeteer.cdpsession.send",children:"CDPSession.send()"})," method and protocol events can be subscribed to with ",(0,t.jsx)(s.code,{children:"CDPSession.on"})," method."]}),"\n",(0,t.jsxs)(s.p,{children:["Useful links: ",(0,t.jsx)(s.a,{href:"https://chromedevtools.github.io/devtools-protocol/",children:"DevTools Protocol Viewer"})," and ",(0,t.jsx)(s.a,{href:"https://github.com/aslushnikov/getting-started-with-cdp/blob/HEAD/README.md",children:"Getting Started with DevTools Protocol"}),"."]}),"\n",(0,t.jsxs)(s.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,t.jsx)(s.code,{children:"CDPSession"})," class."]}),"\n",(0,t.jsx)(s.h2,{id:"example",children:"Example"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-ts",children:"const client = await page.createCDPSession();\nawait client.send('Animation.enable');\nclient.on('Animation.animationCreated', () =>\n console.log('Animation created!')\n);\nconst response = await client.send('Animation.getPlaybackRate');\nconsole.log('playback rate is ' + response.playbackRate);\nawait client.send('Animation.setPlaybackRate', {\n playbackRate: response.playbackRate / 2,\n});\n"})}),"\n",(0,t.jsx)(s.h2,{id:"methods",children:"Methods"}),"\n",(0,t.jsxs)("table",{children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:(0,t.jsx)(s.p,{children:"Method"})}),(0,t.jsx)("th",{children:(0,t.jsx)(s.p,{children:"Modifiers"})}),(0,t.jsx)("th",{children:(0,t.jsx)(s.p,{children:"Description"})})]})}),(0,t.jsxs)("tbody",{children:[(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:(0,t.jsx)("span",{id:"connection",children:(0,t.jsx)(s.a,{href:"/next/api/puppeteer.cdpsession.connection",children:"connection()"})})}),(0,t.jsx)("td",{}),(0,t.jsx)("td",{})]}),(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:(0,t.jsx)("span",{id:"detach",children:(0,t.jsx)(s.a,{href:"/next/api/puppeteer.cdpsession.detach",children
|