PhantomJsCloud Automation API
    Preparing search index...

    Class ElementHandle

    A reference to a DOM element in the page, returned by Page.$, Page.$$, Frame.$, Frame.waitForSelector and the element members below. Everything on :class applies.

    pjsc differences:

    • screenshot ignores path and always returns base64 text.
    • waitForSelector ends with the render; its signal option is ignored.
    • dragEnter / dragOver / drop refuse drag data that names files, and drag / dragAndDrop fail when the browser's drag data names files.
    • Not available: uploadFile and other members that read server files, $x (use the xpath/ selector prefix), and members that reach the browser, its pages or the raw protocol.
    const link = await page.$("a.more");
    const box = await link.boundingBox();
    const png = await link.screenshot();
    await link.click();

    Hierarchy (View Summary)

    Index
    frame: Frame

    The :class that holds the element.

    • The first descendant matching selector, or null.

      Parameters

      • selector: string

      Returns Promise<ElementHandle>

    • Every descendant matching selector.

      Parameters

      • selector: string

      Returns Promise<ElementHandle[]>

    • Runs pageFunction(elements, ...args) on every descendant matching selector.

      Parameters

      • selector: string
      • pageFunction: PageFunction
      • ...args: any[]

      Returns Promise<any>

    • Runs pageFunction(element, ...args) on the first descendant matching selector.

      Parameters

      • selector: string
      • pageFunction: PageFunction
      • ...args: any[]

      Returns Promise<any>

    • The element's Chrome DevTools backend node id.

      Returns Promise<number>

    • The element's bounding box in main-frame CSS pixels, or null when it is not rendered.

      Returns Promise<BoundingBox>

    • The element's content, padding, border and margin boxes, or null when it is not rendered.

      Returns Promise<BoxModel>

    • Scrolls the element into view and clicks it.

      Parameters

      Returns Promise<void>

    • A point in the element that a click would hit, in main-frame CSS pixels.

      Parameters

      • Optionaloffset: Point

      Returns Promise<Point>

    • The :class shown by an <iframe> / <frame> element, else null.

      Returns Promise<Frame>

    • Releases the handle. Disposing a disposed handle does nothing.

      Returns Promise<void>

    • Drags this element and drops it on target.

      Parameters

      • target: ElementHandle
      • Optionaloptions: { delay?: number }

        delay: milliseconds between dragover and drop

      Returns Promise<void>

    • Dispatches dragenter on this element with data; drag data with files is refused.

      Parameters

      Returns Promise<void>

    • Dispatches dragover on this element with data; drag data with files is refused.

      Parameters

      Returns Promise<void>

    • Drops data (or the element being dragged) on this element; drag data with files is refused.

      Parameters

      Returns Promise<void>

    • Runs pageFunction(object, ...args) in the page and returns its result as JSON.

      Parameters

      • pageFunction: PageFunction
      • ...args: any[]

      Returns Promise<any>

    • Runs pageFunction(object, ...args) in the page and returns its result as a :class.

      Parameters

      • pageFunction: PageFunction
      • ...args: any[]

      Returns Promise<JSHandle>

    • Focuses the element.

      Returns Promise<void>

    • Scrolls the element into view and moves the mouse over it.

      Returns Promise<void>

    • Whether the element is hidden.

      Returns Promise<boolean>

    • Whether the element intersects the viewport.

      Parameters

      • Optionaloptions: { threshold?: number }

      Returns Promise<boolean>

    • Whether the element is visible.

      Returns Promise<boolean>

    • The object as JSON (JSON.stringify in the page, then parsed); fails for objects that cannot be stringified.

      Returns Promise<any>

    • Focuses the element and presses key (one key name, such as "Enter" or "ArrowLeft").

      Parameters

      • key: string
      • Optionaloptions: { delay?: number; text?: string }

        delay between keydown and keyup, text

      Returns Promise<void>

    • Scrolls the element into view and returns a screenshot of it as base64 text. path is ignored (no file is written) and encoding is always "base64".

      Parameters

      • Optionaloptions: ScreenshotOptions

        type ("png", "jpeg", "webp"), quality, omitBackground, clip, ...

      Returns Promise<string>

    • Scrolls the element into view.

      Returns Promise<void>

    • Selects values in a <select> element; returns the selected values.

      Parameters

      • ...values: string[]

      Returns Promise<string[]>

    • Scrolls the element into view and taps it.

      Returns Promise<void>

    • This handle when the element's tag is tagName (case-insensitive); fails otherwise.

      Parameters

      • tagName: string

      Returns Promise<ElementHandle>

    • A short description of the referenced object (synchronous).

      Returns string

    • Scrolls the element into view and ends the first active touch. Fails when no touch is active.

      Returns Promise<void>

    • Scrolls the element into view and moves touch (or, without it, the first active touch) to the element's center. Fails when no touch is active.

      Parameters

      Returns Promise<void>

    • Scrolls the element into view and starts a touch at its center; returns the started :class.

      Returns Promise<TouchHandle>

    • Focuses the element and types text.

      Parameters

      • text: string
      • Optionaloptions: { delay?: number }

        delay between key presses in milliseconds

      Returns Promise<void>