Function waitForValue

  • Watches for the value of an input element to match the value provided.

    Parameters

    • ctx: Context

      The context to run the watcher in

    • selector: string

      The selector to watch

    • value: string

      The value to wait for

    • Optional options: WaitValueOptions

      The options to pass to the waitForValueChange function and watcher.

    Returns Promise<ElementHandle<Element>>

    A promise that resolves to the element handler of the input when its value matches the target value. If the value does not match within the specified or default timeout, the promise may reject.

    Example

    const selector = '#username-input';
    const targetValue = 'John Connor';

    waitForValue(ctx, selector, targetValue)
    .then((inputElement) => {
    console.log('Target value reached!', inputElement);
    })
    .catch((error) => {
    console.error('Failed to reach target value:', error);
    });