Function getElementByText

  • Returns an element based on its text content.

    Parameters

    • ctx: Context

      Context object.

    • text: string

      Text to search for.

    • Optionaloptions: FilterOptions

      Options for filtering.

    Returns Promise<null | ElementHandle<Element>>

    The selected element as an element handle.

    const $el = await getElementByText(ctx, 'Save and Submit');
    
    const $el = await getElementByText(ctx, 'Last Name', {filterElementWithTag: 'div'});