playwright-java icon indicating copy to clipboard operation
playwright-java copied to clipboard

[Bug]: waitForHidden() times out even after the element is detached from DOM

Open devTodead opened this issue 6 months ago • 0 comments

Version

1.51.0

Steps to reproduce

  1. Perform the action that makes the progress bar visible.
  2. 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));
  1. 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)

devTodead avatar May 14 '25 03:05 devTodead