microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.03k stars 3.6k forks source link

[Bug]: Hover with trial should not trigger mouseover event #32703

Open muhqu opened 2 weeks ago

muhqu commented 2 weeks ago

Version

1.47.1

Steps to reproduce

  1. Clone my repo https://github.com/muhqu/playwright-issues-with-trial
  2. npm install
  3. npx playwright test
  4. See it fail

Expected behavior

Actual behavior

Additional context

The documentation for trial option…

When set, this method only performs the actionability checks and skips the action. Defaults to false. Useful to wait until the element is ready for the action without performing it.

As the action should be skipped, I would assume that no mousover events should be triggered.

Environment

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 138.27 MB / 64.00 GB
  Binaries:
    Node: 22.3.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.8.1 - /opt/homebrew/bin/npm
    pnpm: 7.28.0 - /opt/homebrew/bin/pnpm
  IDEs:
    VSCode: 1.93.0 - /usr/local/bin/code
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.47.1 => 1.47.1
mxschmitt commented 1 week ago

What is your use-case for hover with trial: true?

The issue with trial: true in click for keydown events is definitely valid, but there can be scenarios that the target element e.g. changes / disappears / remounts on keydown events, hence having a semantically correct trial. In order to not have a potential regression there and break users we would hold back for now.

muhqu commented 1 week ago

My usecase for hover with trial was that I was trying solve a timing issue with the regular hover in our application. The problematic scenario is that on hover over a card an overlay with a button appears. Here locator.hover() fails as it tries to validate that the element under the mouse is still the card but it fails as the overlay intercepts the pointer events… (which might be a bug on its own)

I wanted to use hover({ force:true }) as it skips that check, but then I need to wait until the element is ready to be hoverable… that’s why I wanted to use trial with hover.

muhqu commented 1 week ago

It doesn’t have to be fixed by changing the behavior… it’s also okay to simply adjust the documentation.