Dynamic Elements & Waits
Practice Explicit and Implicit waits. Elements here change, appear, and disappear unpredictably.
1. Dynamic Elements
Challenge Tasks (1)
Tick a task when your script passes it. Tasks with a pass/fail box tick themselves.
Elements appearing later
Elements disappearing
Dynamic IDs
Current ID: dynamic-btn-initial
2. Loading States
Challenge Tasks (2)
Tick a task when your script passes it. Tasks with a pass/fail box tick themselves.
Progress Bar
0% Complete
Skeleton Loader
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.
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: