-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Version
^1.52.0
Steps to reproduce
Simple steps to reproduce:
- You have a page that contains for example a button that shows content when hovering it.
- Within playwright test you go to that page, you wait for the page to load and hydrate, you hover the button, the related content is displayed.
Now 2 possible ways for page reload.
- within playwright test, use
await page.reload()
- button within app that triggers
window.location.reload()
- Again wait for page to load and hydrate, then hover the button ----> NOTHING HAPPENS!
There is a Workaround:
after page reload you need to click somewhere in the page before try to hover, or do await page.locator('body').hover();
before try to hover the button, then it will work.
So it seems somehow the page looses its focus and need to get it back again before being able to do something like hover.
Expected behavior
After page reload the page should be as functional as before the reload, the reload should not end up with the page loosing focus
Actual behavior
It seems like page looses focus after reload, so you need to focus back into page before performing a hover or similar actions.
Additional context
I already tried to use page.bringToFront();
as documentation says "Brings page to front (activates tab)" after the reload and before hovering but it did not work. The page does not seem to be "active".
Additional Info: The Test uses "Desktop Chrome"
Environment
System:
OS: macOS 15.6.1
CPU: (12) arm64 Apple M2 Max
Memory: 632.88 MB / 64.00 GB
Binaries:
Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
npm: 11.5.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
IDEs:
VSCode: 1.5.9 - /usr/local/bin/code
Languages:
Bash: 3.2.57 - /bin/bash
npmPackages:
@playwright/test: ^1.52.0 => 1.53.0