playwright-java
playwright-java copied to clipboard
[Bug]: waitForHidden() times out even after the element is detached from DOM
Version
1.51.0
Steps to reproduce
- Perform the action that makes the progress bar visible.
- Immediately before or after the progress bar is detached, call waitFor to wait for it to disappear.
page.locator("xpath=//app-progress-bar//div[@id='nprogress']")
locator.first().waitFor(new Locator.WaitForOptions()
.setState(WaitForSelectorState.HIDDEN)
.setTimeout(timeout * 1000));
- waitFor does not resolve but continues to wait until the set timeout is reached.
Expected behavior
Logically, once an element has been completely removed from the DOM, it no longer exists to be either "visible" or "hidden". In this case, waitFor State HIDDEN should recognize that the element no longer exists and resolve immediately, instead of waiting for a "hidden" state that can never occur.
Actual behavior
Playwright continues to wait until the set timeout is reached, leading to unnecessary delays in tests and potentially causing inaccurate failures.
Additional context
No response
Environment
Playwright version: 1.51.0 Operating system: Windows 10 Programming language: Java Browser: Chromium (Playwright's bundled version)