PageSourceSearch

https://pptr.dev/assets/js/b79f91d8.04980e1b.js

js pptr.dev collected 2026-09-24 07:05:41 UTC 4,533 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["19038"],{4040(e,n,a){a.r(n),a.d(n,{metadata:()=>t,default:()=>h,frontMatter:()=>s,contentTitle:()=>i,toc:()=>c,assets:()=>d});var t=JSON.parse('{"id":"api/puppeteer.realm.evaluatehandle","title":"Realm.evaluateHandle() method","description":"Evaluates a function in the realm\'s context and returns a JSHandle to the result.","source":"@site/versioned_docs/version-25.12.0/api/puppeteer.realm.evaluatehandle.md","sourceDirName":"api","slug":"/api/puppeteer.realm.evaluatehandle","permalink":"/api/puppeteer.realm.evaluatehandle","draft":false,"unlisted":false,"tags":[],"version":"25.12.0","frontMatter":{"sidebar_label":"Realm.evaluateHandle"},"sidebar":"api","previous":{"title":"Realm.evaluate","permalink":"/api/puppeteer.realm.evaluate"},"next":{"title":"Realm.extension","permalink":"/api/puppeteer.realm.extension"}}'),r=a(74848),l=a(28453);let s={sidebar_label:"Realm.evaluateHandle"},i="Realm.evaluateHandle() method",d={},c=[{value:"Signature",id:"signature",level:3},{value:"Parameters",id:"parameters",level:2},{value:"Example",id:"example",level:2}];function p(e){let n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",p:"p",pre:"pre",strong:"strong",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"realmevaluatehandle-method",children:"Realm.evaluateHandle() method"})}),"\n",(0,r.jsxs)(n.p,{children:["Evaluates a function in the realm's context and returns a ",(0,r.jsx)(n.a,{href:"/api/puppeteer.jshandle",children:"JSHandle"})," to the result."]}),"\n",(0,r.jsxs)(n.p,{children:["If the function passed to ",(0,r.jsx)(n.code,{children:"realm.evaluateHandle"})," returns a Promise, the method will wait for the promise to resolve and return its value."]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.a,{href:"/api/puppeteer.jshandle",children:"JSHandle"})," instances can be passed as arguments to the function."]}),"\n",(0,r.jsx)(n.h3,{id:"signature",children:"Signature"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-typescript",children:"class Realm {\n  abstract evaluateHandle<\n    Params extends unknown[],\n    Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,\n  >(\n    pageFunction: Func | string,\n    ...args: Params\n  ): Promise<HandleFor<Awaited<ReturnType<Func>>>>;\n}\n"})}),"\n",(0,r.jsx)(n.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)(n.p,{children:"Parameter"})}),(0,r.jsx)("th",{children:(0,r.jsx)(n.p,{children:"Type"})}),(0,r.jsx)("th",{children:(0,r.jsx)(n.p,{children:"Description"})})]})}),(0,r.jsxs)("tbody",{children:[(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"pageFunction"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"Func | string"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"A function to be evaluated in the realm."})})]}),(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"args"})}),(0,r.jsx)("td",{children:(0,r.jsx)(n.p,{children:"Params"})}),(0,r.jsx)("td",{children:(0,r.jsxs)(n.p,{children:["Arguments to be passed to the ",(0,r.jsx)(n.code,{children:"pageFunction"}),"."]})})]})]})]}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:"Returns:"})}),"\n",(0,r.jsxs)(n.p,{children:["Promise<",(0,r.jsx)(n.a,{href:"/api/puppeteer.handlefor",children:"HandleFor"}),"<Awaited<ReturnType<Func>>>>"]}),"\n",(0,r.jsxs)(n.p,{children:["A promise that resolves to a ",(0,r.jsx)(n.a,{href:"/api/puppeteer.jshandle",children:"JSHandle"})," containing the result."]}),"\n",(0,r.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"const aHandle = await realm.evaluateHandle(() => document.body);\nconst resultHandle = await realm.evaluateHandle(\n  body => body.innerHTML,\n  aHandle,\n);\n"})})]})}function h(e={}){let{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(p,{...e})}):p(e)}},28453(e,n,a){a.d(n,{R:()=>s,x:()=>i});var t=a(96540);let r={},l=t.createContext(r);function s(e){let n=t.useContext(l);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:s(e.components),t.createElement(l.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.