Repository: puppeteer/puppeteer
File: packages/puppeteer-core/src/api/ElementHandle.ts (TypeScript)

Code before:
   * Focuses the element, and then uses {@link Keyboard.down} and {@link Keyboard.up}.
   *
   * @remarks
   * If `key` is a single character and no modifier keys besides `Shift`
   * are being held down, a `keypress`/`input` event will also be generated.
   * The `text` option can be specified to force an input event to be generated.
   *
   * **NOTE** Modifier keys DO affect `elementHandle.press`. Holding down `Shift`
   * will type the text in upper case.
   *
   * @param key - Name of key to press, such as `ArrowLeft`.
   * See {@link KeyInput} for a list of all key names.
   */
  async press(
    key: KeyInput,
    options?: Readonly<KeyPressOptions>
  ): Promise<void>;
  async press(): Promise<void> {
    throw new Error('Not implemented');
  }

  /**
   * This method returns the bounding box of the element (relative to the main frame),
   * or `null` if the element is not visible.
   */
  async boundingBox(): Promise<BoundingBox | null> {
    if (this.frame.parentFrame()) {
      throw new Error(
        'Elements within nested iframes are currently not supported.'
      );
    }
    // TODO(jrandolf): Use sandboxes when available.
    const box = await this.evaluate(element => {
      if ('offsetParent' in element && element.offsetParent === null) {
        return null;
      }
      const rect = (element as unknown as Element).getBoundingClientRect();
      return {
        x: rect.left,
        y: rect.top,
        width: rect.width,
        height: rect.height,
      };
    });
    return box;
  }

  /**
   * This method returns boxes of the element, or `null` if the element is not visible.
   *
   * @remarks

Review comment (bug):
hm I have just noticed that this is in the wrong file. This would override the CDP implementation in common. Instead this should be defined in common/bidi/ElementHandle where also the sandboxes should be available.

Code after:
   * Focuses the element, and then uses {@link Keyboard.down} and {@link Keyboard.up}.
   *
   * @remarks
   * If `key` is a single character and no modifier keys besides `Shift`
   * are being held down, a `keypress`/`input` event will also be generated.
   * The `text` option can be specified to force an input event to be generated.
   *
   * **NOTE** Modifier keys DO affect `elementHandle.press`. Holding down `Shift`
   * will type the text in upper case.
   *
   * @param key - Name of key to press, such as `ArrowLeft`.
   * See {@link KeyInput} for a list of all key names.
   */
  async press(
    key: KeyInput,
    options?: Readonly<KeyPressOptions>
  ): Promise<void>;
  async press(): Promise<void> {
    throw new Error('Not implemented');
  }

  /**
   * This method returns the bounding box of the element (relative to the main frame),
   * or `null` if the element is not visible.
   */
  async boundingBox(): Promise<BoundingBox | null> {
    throw new Error('Not implemented');
  }

  /**
   * This method returns boxes of the element, or `null` if the element is not visible.
   *
   * @remarks
   *
   * Boxes are represented as an array of points;
   * Each Point is an object `{x, y}`. Box points are sorted clock-wise.
   */
  async boxModel(): Promise<BoxModel | null> {
    throw new Error('Not implemented');
  }

  /**
   * This method scrolls element into view if needed, and then uses
   * {@link Page.(screenshot:3) } to take a screenshot of the element.
   * If the element is detached from DOM, the method throws an error.
   */
  async screenshot(
    this: ElementHandle<Element>,
    options?: ScreenshotOptions
  ): Promise<string | Buffer>;
  async screenshot(this: ElementHandle<Element>): Promise<string | Buffer> {