Skip to main content
Module

x/astral/mod.ts>ElementHandle#evaluate

A high-level puppeteer/playwright-like library for Deno
Latest
method ElementHandle.prototype.evaluate
Re-export
import { ElementHandle } from "https://deno.land/x/astral@0.3.5/mod.ts";

Executes the given function or string whose first argument is a DOM element and returns the result of the execution.

Examples

Example 1

/// <reference lib="dom" />
const value: string = await element.evaluate((element: HTMLInputElement) => element.value)

Example 2

/// <reference lib="dom" />
await element.evaluate(
 (el: HTMLInputElement, key: string, value: string) => el.setAttribute(key, value),
 { args: ["href", "astral"] }
)

Type Parameters

E extends unknown
R extends AnyArray
optional
T = unknown

Parameters

func: ElementEvaluateFunction<E, R, T> | string
optional
evaluateOptions: ElementEvaluateOptions<R>

Returns

Promise<T>