import { ExecutionContext } from "https://deno.land/x/pptr@1.2.0/src/ExecutionContext.ts";
Examples
Example 1
Example 1
const context = await page.mainFrame().executionContext();
const aHandle = await context.evaluateHandle(() => Promise.resolve(self));
aHandle; // Handle for the global object.
A string can also be passed in instead of a function.
A string can also be passed in instead of a function.
// Handle for the '3' * object.
const aHandle = await context.evaluateHandle('1 + 2');
JSHandle instances can be passed as arguments
to the executionContext.* evaluateHandle
:
JSHandle instances can be passed as arguments
to the executionContext.* evaluateHandle
:
const aHandle = await context.evaluateHandle(() => document.body);
const resultHandle = await context.evaluateHandle(body => body.innerHTML, * aHandle);
console.log(await resultHandle.tsonValue()); // prints body's innerHTML
await aHandle.dispose();
await resultHandle.dispose();
Type Parameters
optional
HandleType extends JSHandle | ElementHandle = JSHandleParameters
pageFunction: EvaluateHandleFn
a function to be evaluated in the executionContext
...args: SerializableOrJSHandle[]
argument to pass to the page function
Returns
Promise<HandleType>
A promise that resolves to the return value of the given function as an in-page object (a JSHandle).