Class Selector

Hierarchy

  • Selector

Implements

Methods

  • Parameters

    • s: string
    • options: SelectorOptions

    Returns Selector

  • This method checks the element by performing the following steps:

    1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already checked, this method returns immediately.
    2. Wait for actionability checks on the element, unless force option is set.
    3. Scroll the element into view if needed.
    4. Use page.mouse to click in the center of the element.
    5. Wait for initiated navigations to either succeed or fail, unless noWaitAfter option is set.
    6. Ensure that the element is now checked. If not, this method throws.

    If the element is detached from the DOM at any moment during the action, this method throws.

    When all steps combined have not finished during the specified timeout, this method throws a [TimeoutError]. Passing zero timeout disables this.

    Parameters

    • options: CheckOptions = {}

    Returns Promise<void>

  • This method clicks the element by performing the following steps:

    1. Wait for actionability checks on the element, unless force option is set.
    2. Scroll the element into view if needed.
    3. Use page.mouse to click in the center of the element, or the specified position.
    4. Wait for initiated navigations to either succeed or fail, unless noWaitAfter option is set.

    If the element is detached from the DOM at any moment during the action, this method throws.

    When all steps combined have not finished during the specified timeout, this method throws a [TimeoutError]. Passing zero timeout disables this.

    Parameters

    • options: ClickOptions = {}

    Returns Promise<void>

  • Returns Promise<number>

  • Type Parameters

    • Arg

    • R

    Parameters

    • jsCode: string | ((on: SVGElement | HTMLElement, arg2: Arg) => R | Promise<R>)
    • arg: Arg
    • options: {
          timeout?: number;
      } = {}
      • Optional timeout?: number

    Returns Promise<R>

  • The method finds all elements matching the specified selector and passes an array of matched elements as a first argument to pageFunction. Returns the result of pageFunction invocation.

    If pageFunction returns a [Promise], then selector.evaluateAll(pageFunction[, arg]) would wait for the promise to resolve and return its value.

    Examples:

    const elements = page.selector('div');
    const divCounts = await elements.evaluateAll((divs, min) => divs.length >= min, 10);

    Type Parameters

    • Arg

    • R

    Parameters

    • jsCode: string | ((on: (SVGElement | HTMLElement)[], arg2: Arg) => R | Promise<R>)
    • arg: Arg

      Optional argument to pass to pageFunction.

    Returns Promise<R>

  • This method waits for actionability checks, focuses the element, fills it and triggers an input event after filling. Note that you can pass an empty string to clear the input field.

    If the target element is not an <input>, <textarea> or [contenteditable] element, this method throws an error. However, if the element is inside the <label> element that has an associated control, the control will be filled instead.

    To send fine-grained keyboard events, use selector.type(text[, options]).

    Parameters

    • value: string

      Value to set for the <input>, <textarea> or [contenteditable] element.

    • options: SelectOptionOptions = {}

    Returns Promise<void>

  • Parameters

    • attribute: string
    • options: TimeoutOption = {}

    Returns Promise<null | string>

  • Parameters

    • options: TimeoutOption = {}

    Returns Promise<string>

  • Parameters

    • options: TimeoutOption = {}

    Returns Promise<string>

  • Parameters

    • selectors: (string | ISelector)[]
    • options: {
          timeout?: number;
      } = {}
      • Optional timeout?: number

    Returns Promise<undefined | ISelector>

  • Parameters

    • options: SelectorScreenshotOptions

    Returns Promise<Buffer>

  • Parameters

    • options: TimeoutOption = {}

    Returns Promise<void>

  • This method waits for actionability checks, waits until all specified options are present in the <select> element and selects these options.

    If the target element is not a <select> element, this method throws an error. However, if the element is inside the <label> element that has an associated control, the control will be used instead.

    Returns the array of option values that have been successfully selected.

    Triggers a change and input event once all the provided options have been selected.

    // single selection matching the value
    element.selectOption('blue');

    // single selection matching the label
    element.selectOption({ label: 'Blue' });

    // multiple selection
    element.selectOption(['red', 'green', 'blue']);

    Parameters

    • values: string | string[]

      Options to select. If the <select> has the multiple attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are equivalent to {value:'string'}. Option is considered matching if all specified properties match.

    • options: SelectOptionOptions = {}

    Returns Promise<void>

  • This method waits for actionability checks, then focuses the element and selects all its text content.

    If the element is inside the <label> element that has an associated control, focuses and selects text in the control instead.

    Parameters

    • options: SelectTextOptions = {}

    Returns Promise<void>

  • Parameters

    • Optional accept_if: ((code?: string, error?: string) => Promise<boolean>)
        • (code?: string, error?: string): Promise<boolean>
        • Parameters

          • Optional code: string
          • Optional error: string

          Returns Promise<boolean>

    • options: SolveImageCaptchOptions = {}

    Returns Promise<string>

  • Parameters

    • options: WaitForSelectorOptions = {}

    Returns Promise<Selector>