import { ExecutionContext } from "https://deno.land/x/pptr@1.2.0/src/ExecutionContext.ts";
Examples
Example 1
Example 1
const executionContext = await page.mainFrame().executionContext();
const result = await executionContext.evaluate(() => Promise.resolve(8 * 7))* ;
console.log(result); // prints "56"
A string can also be passed in instead of a function.
A string can also be passed in instead of a function.
console.log(await executionContext.evaluate('1 + 2')); // prints "3"
JSHandle instances can be passed as arguments to the
executionContext.* evaluate
:
JSHandle instances can be passed as arguments to the
executionContext.* evaluate
:
const oneHandle = await executionContext.evaluateHandle(() => 1);
const twoHandle = await executionContext.evaluateHandle(() => 2);
const result = await executionContext.evaluate(
(a, b) => a + b, oneHandle, * twoHandle
);
await oneHandle.dispose();
await twoHandle.dispose();
console.log(result); // prints '3'.
Returns
Promise<ReturnType>
A promise that resolves to the return value of the given function.