PhantomJsCloud Automation API
    Preparing search index...

    Interface ElementHandle<E>

    Represents an in-page DOM element.

    The element handles pjsc returns (from page.$, page.$$, frame.$ and the handle members) are documented at ElementHandle; members marked "Not available" below are not provided.

    interface ElementHandle<E extends Element = Element> {
        $(selector: string): Promise<types.ElementHandle<Element>>;
        $$(selector: string): Promise<types.ElementHandle<Element>[]>;
        $x(expression: string): Promise<types.ElementHandle<Element>[]>;
        asElement(): types.ElementHandle<Element>;
        boundingBox(): Promise<BoundingBox>;
        boxModel(): Promise<BoxModel>;
        click(options?: ClickOptions): Promise<void>;
        contentFrame(): Promise<types.Frame>;
        dispose(): Promise<void>;
        executionContext(): any;
        focus(): Promise<void>;
        getProperties(): Promise<Map<string, types.JSHandle>>;
        getProperty(propertyName: string): Promise<types.JSHandle>;
        hover(): Promise<void>;
        isIntersectingViewport(): Promise<boolean>;
        jsonValue(): Promise<any>;
        press(
            key: string,
            options?: { delay?: number; text?: string },
        ): Promise<void>;
        screenshot(options?: Base64ScreenShotOptions): Promise<string>;
        tap(): Promise<void>;
        toString(): string;
        type(text: string, options?: { delay: number }): Promise<void>;
        uploadFile(...filePaths: string[]): Promise<void>;
    }

    Type Parameters

    • E extends Element = Element

    Hierarchy (View Summary)

    Index
    • The method runs element.querySelector within the page. If no element matches the selector, the return value resolve to null.

      Parameters

      • selector: string

        A selector to query element for

      Returns Promise<types.ElementHandle<Element>>

      0.13.0

    • The method runs element.querySelectorAll within the page. If no elements match the selector, the return value resolve to [].

      Parameters

      • selector: string

        A selector to query element for

      Returns Promise<types.ElementHandle<Element>[]>

      0.13.0

    • Not available: use a selector with the xpath/ prefix instead, e.g. handle.$$("xpath/.//a").

      Parameters

      • expression: string

        XPath expression to evaluate.

      Returns Promise<types.ElementHandle<Element>[]>

    • This method returns the value resolve to the bounding box of the element (relative to the main frame), or null if the element is not visible.

      Returns Promise<BoundingBox>

    • This method returns boxes of the element, or null if the element is not visible. Boxes are represented as an array of points; each Point is an object {x, y}. Box points are sorted clock-wise.

      Returns Promise<BoxModel>

    • This method scrolls element into view if needed, and then uses page.mouse to click in the center of the element. If the element is detached from DOM, the method throws an error.

      Parameters

      Returns Promise<void>

      0.9.0

    • Returns Promise<types.Frame>

      Resolves to the content frame for element handles referencing iframe nodes, or null otherwise.

      1.2.0

    • Stops referencing the element handle.

      Returns Promise<void>

    • Not available.

      Gets the execution context.

      Returns any

    • Calls focus on the element.

      Returns Promise<void>

    • Fetches a single property from the objectHandle.

      Parameters

      • propertyName: string

        The property to get.

      Returns Promise<types.JSHandle>

    • This method scrolls element into view if needed, and then uses page.mouse to hover over the center of the element. If the element is detached from DOM, the method throws an error.

      Returns Promise<void>

    • Resolves to true if the element is visible in the current viewport.

      Returns Promise<boolean>

    • Returns a JSON representation of the object. The JSON is generated by running JSON.stringify on the object in page and consequent JSON.parse in puppeteer.

      Returns Promise<any>

      The method will throw if the referenced object is not stringifiable.

    • Focuses the element, and then uses keyboard.down and keyboard.up.

      Parameters

      • key: string

        Name of key to press, such as ArrowLeft. See USKeyboardLayout for a list of all key names.

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

        The text and delay options.

      Returns Promise<void>

    • This method scrolls element into view if needed, and then uses page.screenshot to take a screenshot of the element. If the element is detached from DOM, the method throws an error.

      Parameters

      Returns Promise<string>

    • This method scrolls element into view if needed, and then uses touchscreen.tap to tap in the center of the element. If the element is detached from DOM, the method throws an error.

      Returns Promise<void>

    • Returns a string representation of an object.

      Returns string

    • Focuses the element, and then sends a keydown, keypress/input, and keyup event for each character in the text.

      Parameters

      • text: string

        A text to type into a focused element.

      • Optionaloptions: { delay: number }

        The typing options.

      Returns Promise<void>

    • Not available: pjsc never reads server files into the page.

      This method expects elementHandle to point to an input element.

      Parameters

      • ...filePaths: string[]

        Sets the value of the file input these paths. If some of the filePaths are relative paths, then they are resolved relative to current working directory.

      Returns Promise<void>