Task Progress0 of 5 Tasks
0%

Dynamic Elements & Waits

Elements that appear late, disappear, change their id, or load behind a skeleton. Each delay is random, so fixed sleeps fail sooner or later. Use explicit waits. Each task ticks itself the moment your script gets it right.

1.Appearing and disappearing

Element that appears laterTo do
Nothing here yet
Goal

Click “Load”, wait for the “I am here now!” button to appear, and click it.

Element that disappearsTo do
Not saved yet
Goal

Click “Save”, wait for the “Saving...” spinner to disappear, then click “Continue”.

Changing idTo do

Current ID: dynamic-btn-initial

Goal

Click the button whose id changes every 3 seconds.

2.Loading states

Progress to 100%To do

0% Complete

Goal

Start the task, wait for 100%, then type the receipt number that appears in the answer box.

Skeleton loaderTo do
Goal

Load the profile, wait for the skeleton to be replaced by real content, and type the username in the answer box.

About this Dynamic & Waits page

A dynamic wait is a rule that pauses a test until an element reaches a state, such as visible, enabled or containing text, instead of sleeping a fixed time. You practice it on a page where content loads asynchronously. In Selenium use WebDriverWait with ExpectedConditions. Playwright and Cypress retry assertions and actions automatically until a timeout.

Screenshot of the Dynamic & Waits practice page on QA Playground. Handle elements appearing asynchronously.
Dynamic & Waits: Handle elements appearing asynchronously.

Frequently asked questions

What is an explicit wait in Selenium?

An explicit wait is a WebDriverWait with a condition and a timeout. Selenium polls the condition, every 500 ms by default, until it returns a truthy value or the timeout expires. Use it for a specific element or state, for example element_to_be_clickable or visibility_of_element_located.

Why is Thread.sleep a bad way to wait for elements?

A fixed sleep is either too short, so the test fails on a slow run, or too long, so every run wastes time. A condition-based wait continues the moment the element is ready and fails only after a timeout you choose, which keeps tests faster and more stable.

Does Playwright need explicit waits?

Usually not. Playwright actions such as click and fill auto-wait for the element to be attached, visible, stable, enabled and able to receive events. Web-first assertions like expect(locator).toBeVisible() also retry until the timeout. Use waitFor only for states no action covers.

How does Cypress handle elements that appear late?

Cypress retries cy.get and most assertions until they pass or the default 4 second timeout ends. If an element needs longer, pass a timeout option to that command, for example cy.get('#result', { timeout: 10000 }). You do not add sleeps.

Should I mix implicit and explicit waits?

No. Selenium documentation warns that mixing them can produce unpredictable wait times. Set the implicit wait to zero and use explicit waits for each condition that needs one.

Free developer tools on Randomly.online

QA Playground is part of Randomly.online. These tools help while you write and debug tests: