Function watchXpath

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

    Parameters

    • ctx: Context

      Context object.

    • selector: string

      Xpath selector to watch.

    • Optional options: Partial<WatchSelectorOptions>

      Enter, leave callbacks and ensureVisible flag.

    Returns Watcher<ElementHandle<Node>>

    Example

    const watcher = watchXpath(ctx, '//div', {
    async enter: (el: ElementHandle) => {
    // Do something with the matched el when it appears
    },
    async leave: (el: ElementHandle) => {
    // Do something with the matched el when it disappears
    },
    });
    // ...
    watcher.stop()

Generated using TypeDoc