puppeteer/assets/js/97f6a35b.b85dd9b7.js

2 lines
7.7 KiB
JavaScript
Raw Normal View History

/*! For license information please see 97f6a35b.b85dd9b7.js.LICENSE.txt */
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[17155],{77396:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>p,contentTitle:()=>i,default:()=>d,frontMatter:()=>a,metadata:()=>l,toc:()=>o});var r=n(85893),s=n(11151);const a={sidebar_label:"Page.$$eval"},i="Page.$$eval() method",l={id:"api/puppeteer.page.__eval",title:"Page.$$eval() method",description:"This method returns all elements matching the selector and passes the resulting array as the first argument to the pageFunction.",source:"@site/../docs/api/puppeteer.page.__eval.md",sourceDirName:"api",slug:"/api/puppeteer.page.__eval",permalink:"/next/api/puppeteer.page.__eval",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{sidebar_label:"Page.$$eval"},sidebar:"api",previous:{title:"Page.$$",permalink:"/next/api/puppeteer.page.__"},next:{title:"Page.$eval",permalink:"/next/api/puppeteer.page._eval"}},p={},o=[{value:"Signature:",id:"signature",level:4},{value:"Parameters",id:"parameters",level:2},{value:"Remarks",id:"remarks",level:2},{value:"Example 1",id:"example-1",level:2},{value:"Example 2",id:"example-2",level:2},{value:"Example 3",id:"example-3",level:2}];function c(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",h4:"h4",p:"p",pre:"pre",strong:"strong",...(0,s.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(t.h1,{id:"pageeval-method",children:"Page.$$eval() method"}),"\n",(0,r.jsxs)(t.p,{children:["This method returns all elements matching the selector and passes the resulting array as the first argument to the ",(0,r.jsx)(t.code,{children:"pageFunction"}),"."]}),"\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:"class Page {\n $$eval<\n Selector extends string,\n Params extends unknown[],\n Func extends EvaluateFuncWith<\n Array<NodeFor<Selector>>,\n Params\n > = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>,\n >(\n selector: Selector,\n pageFunction: Func | string,\n ...args: Params\n ): Promise<Awaited<ReturnType<Func>>>;\n}\n"})}),"\n",(0,r.jsx)(t.h2,{id:"parameters",children:"Parameters"}),"\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:"Parameter"})}),(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)(t.p,{children:"selector"})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Selector"})}),(0,r.jsx)("td",{children:(0,r.jsxs)(t.p,{children:[(0,r.jsx)(t.a,{href:"https://pptr.dev/guides/page-interactions#query-selectors",children:"selector"})," to query page for. ",(0,r.jsx)(t.a,{href:"https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors",children:"CSS selectors"})," can be passed as-is and a ",(0,r.jsx)(t.a,{href:"https://pptr.dev/guides/page-interactions#p-selectors",children:"Puppeteer-specific seletor syntax"})," allows quering by ",(0,r.jsx)(t.a,{href:"https://pptr.dev/guides/page-interactions#text-selectors--p-text",children:"text"}),", ",(0,r.jsx)(t.a,{href:"https://pptr.dev/guides/page-interactions#aria-selectors--p-aria",children:"a11y role and name"}),", and ",(0,r.jsx)(t.a,{href:"https://pptr.dev/guides/page-interactions#xpath-selectors--p-xpath",children:"xpath"})," and ",(0,r.jsx)(t.a,{href:"https://pptr.dev/guides/page-interactions#-and--combinators",children:"combining these queries across shadow roots"}),". Alternatively, you can specify a selector type using a prefix ",(0,r.jsx)(t.a,{href:"https://pptr.dev/guides/page-interactions#built-in-selectors",children:"prefix"}),"."]})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"pageFunction"})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"Func | string"})}),(0,r.jsx)("td",{children:(0,r.jsx)(t.p,{children:"the function to be evaluated in the page context. Will be passed an array of matching elements as i