Skip to content

[Bug]: Parameter position of locator.click does not work as expected #38697

@ipeneva

Description

@ipeneva

Version

1.56.0

Steps to reproduce

I need to click in the center of the element. I used the following code

    await this.selectItem(item).click({ trial: true });
    const box = await this.selectItem(item).boundingBox();
    this.logger.info(`Bounding box after 1st click: ${JSON.stringify(box)}`);
    await this.selectItem(item).click({
      position: {
        // x: 0,
        x: box!.width / 2,
        y: box!.height / 2,
      },
    });

The cursor is positioned in the center only before the action. But for the action it appears on the upper border of the element.

Expected behavior

The click is executed in the center of the element

Actual behavior

Before the action the cursor is positioned in the middle of the element

Image

On the action the position is the default (horizontal: middle, vertical: up)

Image

Additional context

No response

Environment

System
  OS: Ubuntu 24.04.2 LTS
  CPU: (16) arm65

Binaries:
  Node: 22.14.0
  pnpm: 9.15.4

npmPackages:
  @playwright/test: 1.56.0 (I tried as well version 1.57.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions