Recommended Free Tools
Wait for the specific state your test needs: use hidden when the element must no longer be visible, and detached or not exist when it must be removed from the DOM. In a single-page app, use a framework wait or retrying assertion rather than a fixed sleep; the page can keep changing after its initial document load.
Choose what “disappear” means
An element can stop appearing on screen while remaining mounted in the DOM—for example, because it is hidden. Removal is a different result: the element is no longer present. Choose the condition that matches the behavior under test, such as a spinner becoming invisible versus a modal being unmounted.
As an Amazon Associate I earn from qualifying purchases.
- Wait for hidden: use when the user should no longer see the element, whether it is hidden or removed.
- Wait for removal: use when the test specifically requires the element to leave the DOM.
Playwright
Use a locator’s waitFor method. The hidden state succeeds if the element is hidden or detached; use detached when DOM removal is required. Playwright supports attached, detached, visible, and hidden states. A state that already holds satisfies the wait immediately; if it does not arrive before the configured timeout, the call throws. For hidden and detached, the method returns null. See the Playwright Locator API.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →await page.locator('[data-testid="loading"]').waitFor({ state: 'hidden' });
For strict removal, change the state:
await page.locator('[data-testid="loading"]').waitFor({ state: 'detached' });
Prefer locators and web-first assertions in current Playwright code. The older selector-based Page APIs are discouraged in favor of locator-based waits and assertions. Do not use page.isHidden() as a wait: it checks immediately, and its timeout option is ignored. The API documentation covers Page.isHidden.
#1 Best Overall
Selenium with Python
Use WebDriverWait with an inverse visibility condition when the element must no longer be visible. This example follows Selenium’s Python API; adapt the locator tuple to your selector. For a CSS selector, use (By.CSS_SELECTOR, '.loading').
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
WebDriverWait(driver, 10).until_not(
EC.visibility_of_element_located((By.ID, "exampleId"))
)
The wait polls the supplied condition until it reaches the requested result or times out. For a direct predicate, Selenium’s Python API also demonstrates until_not(lambda x: x.find_element(...).is_displayed()). This waits for no longer visible, not necessarily for DOM removal. Use a condition that expresses the required state if your test must assert absence. See the Selenium Python WebDriverWait API.
Single-page apps can update after document readiness, so synchronization with the expected state is more reliable than guessing a delay. Selenium warns not to mix implicit and explicit waits: doing so can produce unpredictable wait durations. Its waiting strategies guide explains the distinction.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Cypress
For DOM removal, query the element and assert that it does not exist. Cypress retries the DOM query and assertion until they pass or time out.
cy.get('[data-testid="loading"]').should('not.exist');
Use a visibility assertion instead if the element can remain mounted but must no longer be visible. A nonexistence assertion is specifically about absence; it is not interchangeable with visibility. Cypress documents retrying DOM queries and the .should('not.exist') pattern in its Introduction to Cypress.
Which wait should you use?
| Framework | Pattern | What it establishes | Wait behavior |
|---|---|---|---|
| Playwright | locator.waitFor({ state: 'hidden' }) or state: 'detached' |
hidden accepts hidden or removed; detached requires removal |
Waits for the requested state or times out; succeeds immediately if the state already holds |
| Selenium Python | WebDriverWait(...).until_not(...) |
The documented visibility example waits until no longer visible | Polls the condition until it passes or times out |
| Cypress | cy.get(...).should('not.exist') |
Asserts that the element is absent from the DOM | Retries the query and assertion until they pass or time out |
Common failures and fixes
The wait times out, but the page looks finished
Check whether the element is actually hidden or removed. A selector may match a different element, or the app may leave the original mounted but invisible. If invisibility is sufficient, use a hidden or visibility condition; if removal is essential, keep the detached or absence condition and verify the selector targets the element that should be removed.
Rank #3
The test passes while the element is still in the DOM
The test likely checks visibility rather than removal. Use Playwright’s detached state or Cypress’s .should('not.exist') for DOM absence. A condition for no longer visible does not prove that the element was unmounted.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The test is flaky with a fixed sleep
A fixed delay can be too short when a transition takes longer than expected and waste time when it finishes sooner. Replace it with the framework’s state-based wait or retrying assertion. Selenium describes race conditions between the app and automation as a cause of flaky tests in its waiting strategies guide.
Wait duration is unexpectedly long in Selenium
Check whether the test combines implicit and explicit waits. Selenium warns against mixing them because the resulting durations can be unpredictable; use a consistent synchronization strategy.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Or skip the browser setup
If you need an image or PDF of a page rather than an automated assertion about DOM state, ScreenshotNeo provides a one-request screenshot API. It does not replace a test-framework wait: its endpoint captures a page; it does not assert that your app’s element reached a particular state.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Before capture it can accept cookie or consent banners and remove known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.
Free tools Windows power users keep installed
One-click scans. No signup required.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Frequently Asked Questions
What is the difference between hidden and detached?
Hidden means the element is not visible; detached means it is no longer in the DOM. Use the latter only when removal itself is what the test must prove.
Best Value
Does a Playwright hidden wait pass if the element is removed?
Yes. Playwright’s hidden state accepts either hidden or detached; use detached for a strict removal check.
Can Selenium’s until_not visibility wait prove DOM removal?
No. The documented inverse visibility condition establishes that the element is no longer visible, not necessarily that it has been removed.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




