/** * @license * Copyright 2023 Google Inc. * SPDX-License-Identifier: Apache-2.0 */ import type { Protocol } from 'devtools-protocol'; import type { Frame } from '../api/Frame.js'; import type { AwaitableIterable, ElementFor, EvaluateFuncWith, HandleFor, HandleOr, NodeFor } from '../common/types.js'; import type { KeyInput } from '../common/USKeyboardLayout.js'; import { _isElementHandle } from './ElementHandleSymbol.js'; import type { KeyboardTypeOptions, KeyPressOptions, MouseClickOptions, TouchHandle } from './Input.js'; import { JSHandle } from './JSHandle.js'; import type { Locator } from './locators/locators.js'; import type { QueryOptions, ScreenshotOptions, WaitForSelectorOptions } from './Page.js'; /** * @public */ export type Quad = [Point, Point, Point, Point]; /** * @public */ export interface BoxModel { content: Quad; padding: Quad; border: Quad; margin: Quad; width: number; height: number; } /** * @public */ export interface BoundingBox extends Point { /** * the width of the element in pixels. */ width: number; /** * the height of the element in pixels. */ height: number; } /** * @public */ export interface Offset { /** * x-offset for the clickable point relative to the top-left corner of the border box. */ x: number; /** * y-offset for the clickable point relative to the top-left corner of the border box. */ y: number; } /** * @public */ export interface ClickOptions extends MouseClickOptions { /** * Offset for the clickable point relative to the top-left corner of the border box. */ offset?: Offset; /** * An experimental debugging feature. If true, inserts an element into the * page to highlight the click location for 10 seconds. Might not work on all * pages and does not persist across navigations. * * @experimental */ debugHighlight?: boolean; } /** * @public */ export interface Point { x: number; y: number; } /** * @public */ export interface ElementScreenshotOptions extends ScreenshotOptions { /** * @defaultValue `true` */ scrollIntoView?: boolean; } /** * A given method will have it's `this` replaced with an isolated version of * `this` when decorated with this decorator. * * All changes of isolated `this` are reflected on the actual `this`. * * @internal */ export declare function bindIsolatedHandle>(target: (this: This, ...args: any[]) => Promise, _: unknown): typeof target; /** * ElementHandle represents an in-page DOM element. * * @remarks * ElementHandles can be created with the {@link Page.$} method. * * ```ts * import puppeteer from 'puppeteer'; * * const browser = await puppeteer.launch(); * const page = await browser.newPage(); * await page.goto('https://example.com'); * const hrefElement = await page.$('a'); * await hrefElement.click(); * // ... * ``` * * ElementHandle prevents the DOM element from being garbage-collected unless the * handle is {@link JSHandle.dispose | disposed}. ElementHandles are auto-disposed * when their associated frame is navigated away or the parent * context gets destroyed. * * ElementHandle instances can be used as arguments in {@link Page.$eval} and * {@link Page.evaluate} methods. * * If you're using TypeScript, ElementHandle takes a generic argument that * denotes the type of element the handle is holding within. For example, if you * have a handle to a `` element matching `selector`, the method * throws an error. * * @example * * ```ts * handle.select('blue'); // single selection * handle.select('red', 'green', 'blue'); // multiple selections * ``` * * @param values - Values of options to select. If the `