Function watchSelector

  • Watches an element by CSS selector, and executes code when it appears or disappears.

    Parameters

    • ctx: Context

      Context object.

    • selector: string

      CSS selector to watch.

    • Optional options: Partial<WatchSelectorOptions>

      Enter, leave callbacks and ensureVisible flag.

    Returns Watcher<ElementHandle<Element>>

    Example

    const watcher = watchSelector(ctx, '.selector', {
    async enter: (el: ElementHandle) => {
    // do something with matched el when appeared
    },
    async leave: (el: ElementHandle) => {
    // do something with matched el when disappeared
    },
    });
    // ...
    watcher.stop()

Generated using TypeDoc