What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use an explicit wait when a Ruby Selenium test needs the browser to reach a particular state: create Selenium::WebDriver::Wait, then call until with a block that returns a truthy value when it is safe to continue. This replaces arbitrary sleep delays with condition-based polling.
Wait for the state your next action needs
An explicit wait repeatedly evaluates a condition until the block returns a truthy value or the timeout expires. For example, check that a submit button is displayed before clicking it:
wait = Selenium::WebDriver::Wait.new(timeout: 10, interval: 0.2)
wait.until { driver.find_element(id: 'submit').displayed? }
driver.find_element(id: 'submit').click
In this example, the element lookup is inside the block, so each polling attempt checks the current DOM rather than retaining an element reference that the page may have replaced. The timeout and interval are illustrative; choose values appropriate to the application and test environment. Selenium’s current guide also shows a two-second timeout and 0.3-second interval as example settings, not universal recommendations. Selenium’s Waiting Strategies guide describes explicit waits as loops that poll for a specific condition before continuing.
Choose timeout, interval, and ignored exceptions
The Ruby wait API accepts a timeout, polling interval, optional message, optional message provider, and exceptions to ignore. The until method returns the truthy value produced by the block, retries configured ignored exceptions, sleeps for the interval between attempts, and raises Selenium::WebDriver::Error::TimeoutError when its deadline passes. Check the API reference matching your installed Selenium gem for version-specific defaults. Ruby Wait API reference.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →#1 Best Overall
By default, Selenium::WebDriver::Error::NoSuchElementError is ignored, which is useful when the target has not yet appeared. You can add another transient exception when there is a reason to retry it:
errors = [Selenium::WebDriver::Error::NoSuchElementError,
Selenium::WebDriver::Error::ElementNotInteractableError]
wait = Selenium::WebDriver::Wait.new(
timeout: 10,
interval: 0.2,
ignore: errors
)
wait.until { driver.find_element(id: 'submit').displayed? }
Ignore exceptions sparingly. An exception not in the configured list is raised immediately rather than swallowed by the wait loop. A displayed element is also not necessarily ready for every possible interaction: make the condition correspond to what the test will do next.
Rank #2
Explicit and implicit waits are different
| Wait type | Scope | What triggers another attempt? | Configuration |
|---|---|---|---|
| Implicit | Element-location calls across the WebDriver session | A lookup waits for an element to be found | Session-level setting; Selenium’s guide says the default is zero |
| Explicit | A particular condition in a wait block | The block is evaluated until it returns a truthy value or times out | Per wait: timeout, interval, message options, and ignored exceptions |
Use an explicit wait when the test depends on a particular state, such as an element becoming visible. Avoid combining implicit and explicit waits: Selenium warns that their interaction can produce unpredictable total wait times. Its guide gives an example where a nominal 10-second implicit wait and 15-second explicit wait can lead to a timeout after 20 seconds. See Selenium’s warning on mixing waits.
Replace fixed sleeps with targeted conditions
A fixed sleep waits the same length of time whether the page is ready quickly or slowly. An explicit wait continues as soon as its condition is true, while still allowing a maximum deadline. Before writing the wait, identify the evidence the next step requires: visibility before typing, for example, or another condition your application exposes. A locator finding an element alone does not establish that it is visible or interactable.
Rank #3
Troubleshoot wait failures
- The wait times out: The block did not return a truthy value before the deadline. Verify that the locator identifies the intended element, that the condition matches the state the page actually reaches, and that the timeout suits the environment.
- The failure is immediate: The wait only retries configured ignored exceptions. By default, that is
NoSuchElementError; other exceptions are not automatically suppressed. Add an exception only when retrying it is appropriate. - Wait duration is longer or less predictable than expected: Look for an implicit wait configured elsewhere in the test setup. Selenium cautions against combining implicit and explicit waits.
- The element is found but the action fails: Finding an element is not proof it is displayed or interactable. Wait for the state needed by the next operation; Selenium’s Ruby example checks
displayed?before typing.
Or skip the browser setup
If your goal is a website screenshot rather than an interactive Selenium test, ScreenshotNeo can capture a URL with one GET request. Cookie banners are accepted and removed before the shot, along with known consent banners, newsletter popups, and chat widgets; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. Its MCP server gives AI agents screenshot, page-info, and PDF-capture tools.
ScreenshotNeo API documentation
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Free includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Learn about ScreenshotNeo, or sign up free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Frequently Asked Questions
What does `wait.until` return?
It returns the truthy value returned by the condition block.
Quick Recap
Best Value
Rank #4
Which error does a Ruby Selenium wait ignore by default?
`Selenium::WebDriver::Error::NoSuchElementError`.
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.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitches




