Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Methods

$

  • The method queries frame for the selector. If there's no such element within the frame, the method will resolve to null.

    Parameters

    • selector: string

    Returns Promise<null | ElementHandle<Element>>

$$

  • The method runs document.querySelectorAll within the frame. If no elements match the selector, the return value resolve to [].

    Parameters

    • selector: string

    Returns Promise<ElementHandle<Element>[]>

$$eval

  • This method runs Array.from(document.querySelectorAll(selector)) within the context and passes it as the first argument to pageFunction.

    If pageFunction returns a Promise, then $$eval would wait for the promise to resolve and return its value.

    Type parameters

    • R

    Parameters

    • selector: string

      A selector to query for

    • pageFunction: (elements: Element[]) => R | Promise<R>

      Function to be evaluated in browser context

        • (elements: Element[]): R | Promise<R>
        • Parameters

          • elements: Element[]

          Returns R | Promise<R>

    Returns Promise<WrapElementHandle<R>>

    Promise which resolves to the return value of pageFunction

  • This method runs Array.from(document.querySelectorAll(selector)) within the context and passes it as the first argument to pageFunction.

    If pageFunction returns a Promise, then $$eval would wait for the promise to resolve and return its value.

    Type parameters

    • R

    • X1

    Parameters

    • selector: string

      A selector to query for

    • pageFunction: (elements: Element[], x1: UnwrapElementHandle<X1>) => R | Promise<R>

      Function to be evaluated in browser context

    • x1: X1

      First argument to pass to pageFunction

    Returns Promise<WrapElementHandle<R>>

    Promise which resolves to the return value of pageFunction

  • This method runs Array.from(document.querySelectorAll(selector)) within the context and passes it as the first argument to pageFunction.

    If pageFunction returns a Promise, then $$eval would wait for the promise to resolve and return its value.

    Type parameters

    • R

    • X1

    • X2

    Parameters

    Returns Promise<WrapElementHandle<R>>

    Promise which resolves to the return value of pageFunction

  • This method runs Array.from(document.querySelectorAll(selector)) within the context and passes it as the first argument to pageFunction.

    If pageFunction returns a Promise, then $$eval would wait for the promise to resolve and return its value.

    Type parameters

    • R

    • X1

    • X2

    • X3

    Parameters

    Returns Promise<WrapElementHandle<R>>

    Promise which resolves to the return value of pageFunction

  • This method runs Array.from(document.querySelectorAll(selector)) within the context and passes it as the first argument to pageFunction.

    If pageFunction returns a Promise, then $$eval would wait for the promise to resolve and return its value.

    Type parameters

    • R

    Parameters

    • selector: string

      A selector to query for

    • pageFunction: (elements: Element[], ...args: any[]) => R | Promise<R>

      Function to be evaluated in browser context

        • (elements: Element[], ...args: any[]): R | Promise<R>
        • Parameters

          • elements: Element[]
          • Rest ...args: any[]

          Returns R | Promise<R>

    • Rest ...args: SerializableOrJSHandle[]

      Arguments to pass to pageFunction

    Returns Promise<WrapElementHandle<R>>

    Promise which resolves to the return value of pageFunction

$eval

  • This method runs document.querySelector within the context and passes it as the first argument to pageFunction. If there's no element matching selector, the method throws an error.

    If pageFunction returns a Promise, then $eval would wait for the promise to resolve and return its value.

    Type parameters

    • R

    Parameters

    • selector: string

      A selector to query for

    • pageFunction: (element: Element) => R | Promise<R>

      Function to be evaluated in browser context

        • (element: Element): R | Promise<R>
        • Parameters

          • element: Element

          Returns R | Promise<R>

    Returns Promise<WrapElementHandle<R>>

    Promise which resolves to the return value of pageFunction

  • This method runs document.querySelector within the context and passes it as the first argument to pageFunction. If there's no element matching selector, the method throws an error.

    If pageFunction returns a Promise, then $eval would wait for the promise to resolve and return its value.

    Type parameters

    • R

    • X1

    Parameters

    • selector: string

      A selector to query for

    • pageFunction: (element: Element, x1: UnwrapElementHandle<X1>) => R | Promise<R>

      Function to be evaluated in browser context

    • x1: X1

      First argument to pass to pageFunction

    Returns Promise<WrapElementHandle<R>>

    Promise which resolves to the return value of pageFunction

  • This method runs document.querySelector within the context and passes it as the first argument to pageFunction. If there's no element matching selector, the method throws an error.

    If pageFunction returns a Promise, then $eval would wait for the promise to resolve and return its value.

    Type parameters

    • R

    • X1

    • X2

    Parameters

    Returns Promise<WrapElementHandle<R>>

    Promise which resolves to the return value of pageFunction

  • This method runs document.querySelector within the context and passes it as the first argument to pageFunction. If there's no element matching selector, the method throws an error.

    If pageFunction returns a Promise, then $eval would wait for the promise to resolve and return its value.

    Type parameters

    • R

    • X1

    • X2

    • X3

    Parameters

    Returns Promise<WrapElementHandle<R>>

    Promise which resolves to the return value of pageFunction

  • This method runs document.querySelector within the context and passes it as the first argument to pageFunction. If there's no element matching selector, the method throws an error.

    If pageFunction returns a Promise, then $eval would wait for the promise to resolve and return its value.

    Type parameters

    • R

    Parameters

    • selector: string

      A selector to query for

    • pageFunction: (element: Element, ...args: any[]) => R | Promise<R>

      Function to be evaluated in browser context

        • (element: Element, ...args: any[]): R | Promise<R>
        • Parameters

          • element: Element
          • Rest ...args: any[]

          Returns R | Promise<R>

    • Rest ...args: SerializableOrJSHandle[]

      Arguments to pass to pageFunction

    Returns Promise<WrapElementHandle<R>>

    Promise which resolves to the return value of pageFunction

$x

  • The method evaluates the XPath expression.

    Parameters

    • expression: string

      XPath expression to evaluate.

    Returns Promise<ElementHandle<Element>[]>

addScriptTag

  • Adds a <script> tag into the page with the desired url or content.

    Parameters

    Returns Promise<void>

addStyleTag

  • Adds a <link rel="stylesheet"> tag into the page with the desired url or a <style type="text/css"> tag with the content.

    Parameters

    Returns Promise<void>

childFrames

  • Returns Frame[]

click

  • click(selector: string, options?: ClickOptions): Promise<void>
  • This method fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to click in the center of the element. If there's no element matching selector, the method throws an error.

    Parameters

    • selector: string

      A selector to search for element to click. If there are multiple elements satisfying the selector, the first will be clicked.

    • Optional options: ClickOptions

      Specifies the click options.

    Returns Promise<void>

content

  • content(): Promise<string>
  • Gets the full HTML contents of the page, including the doctype.

    Returns Promise<string>

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: any, ...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: any, ...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

  • Execution context associated with this frame.

    Returns Promise<ExecutionContext>

focus

  • focus(selector: string): Promise<void>
  • This method fetches an element with selector and focuses it.

    Parameters

    • selector: string

    Returns Promise<void>

goto

  • Navigates to a URL.

    Parameters

    • url: string

      URL to navigate page to. The url should include scheme, e.g. https://

    • Optional options: DirectNavigationOptions

      The navigation parameters.

    Returns Promise<null | Response>

hover

  • hover(selector: string): Promise<void>
  • This method fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to hover over the center of the element. If there's no element matching selector, the method throws an error.

    Parameters

    • selector: string

      A selector to search for element to hover. If there are multiple elements satisfying the selector, the first will be hovered.

    Returns Promise<void>

isDetached

  • isDetached(): boolean
  • Returns true if the frame has been detached, or false otherwise.

    Returns boolean

name

  • name(): string
  • Returns frame's name attribute as specified in the tag.

    Returns string

parentFrame

  • parentFrame(): null | Frame
  • Returns parent frame, if any. Detached frames and main frames return null.

    Returns null | Frame

select

  • select(selector: string, ...values: string[]): Promise<string[]>
  • Triggers a change and input event once all the provided options have been selected. If there's no <select> element matching selector, the method throws an error.

    Parameters

    • selector: string

      A selector to query page for.

    • Rest ...values: string[]

      Values of options to select. If the <select> has the multiple attribute, all values are considered, otherwise only the first one is taken into account.

    Returns Promise<string[]>

setContent

  • Sets the page content.

    Parameters

    • html: string

      HTML markup to assign to the page.

    • Optional options: NavigationOptions

      The navigation parameters.

    Returns Promise<void>

tap

  • tap(selector: string): Promise<void>
  • This method fetches an element with selector, scrolls it into view if needed, and then uses page.touchscreen to tap in the center of the element.

    Parameters

    • selector: string

      A selector to search for element to tap. If there are multiple elements satisfying the selector, the first will be tapped.

    Returns Promise<void>

title

  • title(): Promise<string>
  • Returns page's title.

    Returns Promise<string>

type

  • type(selector: string, text: string, options?: { delay: number }): Promise<void>
  • Sends a keydown, keypress/input, and keyup event for each character in the text.

    Parameters

    • selector: string

      A selector of an element to type into. If there are multiple elements satisfying the selector, the first will be used.

    • text: string
    • Optional options: { delay: number }
      • delay: number

    Returns Promise<void>

url

  • url(): string
  • Returns frame's url.

    Returns string

waitFor

waitForFunction

waitForNavigation

waitForSelector

waitForTimeout

  • waitForTimeout(milliseconds: number): Promise<void>
  • Causes your script to wait for the given number of milliseconds.

    remarks

    It's generally recommended to not wait for a number of seconds, but instead use Frame.waitForSelector, Frame.waitForXPath or Frame.waitForFunction to wait for exactly the conditions you want.

    example

    Wait for 1 second:

    await frame.waitForTimeout(1000);
    

    Parameters

    • milliseconds: number

      the number of milliseconds to wait.

    Returns Promise<void>

waitForXPath

Generated using TypeDoc