Options
All
  • Public
  • Public/Protected
  • All
Menu

JSHandle represents an in-page JavaScript object.

Type parameters

  • T = any

Hierarchy

Index

Methods

asElement

  • Returns a ElementHandle

    Returns null | ElementHandle<Element>

dispose

  • dispose(): Promise<void>
  • Stops referencing the element handle.

    Returns Promise<void>

evaluate

  • Evaluates a function in the browser context. If the function, passed to the frame.evaluate, returns a Promise, then frame.evaluate would wait for the promise to resolve and return its value. If the function passed into frame.evaluate returns a non-Serializable value, then frame.evaluate resolves to undefined.

    Type parameters

    Parameters

    Returns Promise<EvaluateFnReturnType<T> extends PromiseLike<U> ? U : EvaluateFnReturnType<T>>

evaluateHandle

  • evaluateHandle<HandlerType>(pageFunction: string | ((arg1: T, ...args: any[]) => any), ...args: SerializableOrJSHandle[]): Promise<HandlerType>
  • The only difference between evaluate and evaluateHandle is that evaluateHandle returns in-page object (JSHandle). If the function, passed to the evaluateHandle, returns a Promise, then evaluateHandle would wait for the promise to resolve and return its value. The TypeScript definitions assume that evaluateHandle returns a JSHandle, but if you know it's going to return an ElementHandle, pass it as the generic argument:

    Type parameters

    Parameters

    • pageFunction: string | ((arg1: T, ...args: any[]) => any)

      a function that is run within the page

    • Rest ...args: SerializableOrJSHandle[]

      arguments to be passed to the pageFunction

    Returns Promise<HandlerType>

executionContext

  • Gets the execution context.

    Returns ExecutionContext

getProperties

  • getProperties(): Promise<Map<string, JSHandle<any>>>
  • Returns a map with property names as keys and JSHandle instances for the property values.

    Returns Promise<Map<string, JSHandle<any>>>

getProperty

  • getProperty(propertyName: string): Promise<JSHandle<any>>
  • Fetches a single property from the objectHandle.

    Parameters

    • propertyName: string

      The property to get.

    Returns Promise<JSHandle<any>>

jsonValue

  • jsonValue(): Promise<unknown>
  • Returns a JSON representation of the object. The JSON is generated by running JSON.stringify on the object in page and consequent JSON.parse in puppeteer.

    throws

    The method will throw if the referenced object is not stringifiable.

    Returns Promise<unknown>

Generated using TypeDoc