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 glitchesUse WebDriverWait with a predicate that describes the browser state your next action needs. Selenium repeatedly evaluates that condition until it succeeds or the timeout expires, so you can wait for a result to appear instead of pausing for a fixed number of seconds.
What WebDriverWait does
WebDriverWait is an explicit wait for an IWebDriver. It is in the OpenQA.Selenium.Support.UI namespace, in the Selenium.WebDriver assembly, and derives from DefaultWait<IWebDriver>. Construct it with the driver and a TimeSpan, then call Until with a condition. Selenium WebDriverWait API
Unlike a fixed sleep, an explicit wait checks the condition repeatedly and returns as soon as it succeeds. That makes the condition—not an assumed page-load duration—the definition of readiness. Selenium waits guide
Basic C# example: wait for an element to be visible
This example waits up to 10 seconds for an element with the ID results to be displayed, then returns the element for the next test step.
Recommended Free Tools
#1 Best Overall
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement result = wait.Until(d =>
{
var element = d.FindElement(By.Id("results"));
return element.Displayed ? element : null;
});
The returned type is an IWebElement, so the successful condition can supply the object the test needs. Depending on the target framework and nullable-reference-type settings, your project may require a nullable annotation or other adjustment for the null return.
How Until decides the wait is complete
Until repeatedly passes the driver to the function you provide. A boolean condition succeeds when it returns true; an object-returning condition succeeds when it returns a non-null object. In either case, Until returns the successful result. If the condition throws an exception that is not configured to be ignored, that exception propagates. If the condition does not succeed before the timeout, the wait ends with a timeout failure. Selenium DefaultWait<T> API Selenium IWait<T> API
Wait for a boolean condition
If the next step only needs a condition to become true, return a boolean:
Rank #2
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(d => d.FindElement(By.Id("revealed")).Displayed);
Selenium’s C# guide demonstrates this pattern with a two-second timeout. That value is an example, not a general recommendation; choose a timeout appropriate to the application and test environment. Selenium waits guide
Choose the state the next action actually needs
Finding an element establishes that it can be located; it does not establish that it is visible, interactable, or in the application-specific state your test needs. Make the predicate check the relevant condition. For example, use a visibility check before reading a visible result, or check a title or other application state when that is what indicates completion.
wait.Until(d => d.Title.Contains("Dashboard"));
Set the timeout, polling interval, and ignored exceptions
The standard constructor accepts an IWebDriver and a timeout. DefaultWait<T> documents defaults of 500 milliseconds for both its timeout and polling interval. In ordinary explicit-wait code, set the timeout in the WebDriverWait constructor rather than relying on the inherited default. The API also documents a constructor overload that accepts a clock and sleep interval. WebDriverWait API DefaultWait<T> API
Change the polling interval only when you have a reason to do so. A shorter interval means more frequent condition checks; it does not make an unsuitable condition meaningful. Selenium’s C# wait guide shows a 300-millisecond interval as an example, not a universal setting.
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10))
{
PollingInterval = TimeSpan.FromMilliseconds(300)
};
You can configure specific exception types to be ignored during polling. Ignore only errors that are expected to be transient for the condition you are checking:
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10))
{
PollingInterval = TimeSpan.FromMilliseconds(300)
};
wait.IgnoreExceptionTypes(typeof(ElementNotInteractableException));
Selenium uses ElementNotInteractableException in a guide example. It is not a blanket recommendation: exceptions outside the ignore list propagate, which helps expose real test failures instead of silently retrying them. Selenium waits guide DefaultWait<T> API
Rank #4
Use lambdas instead of Expected Conditions in Selenium 4 C#
Selenium’s documentation says, “.NET stopped supporting Expected Conditions in Selenium 4 to minimize maintenance hassle and redundancy.” Express the condition directly as a C# lambda passed to Until, as in the visibility and title examples above. Do not copy Expected Conditions examples intended for another Selenium language into a .NET test. Selenium Expected Conditions documentation
Keep implicit waits modest when using explicit waits
Selenium’s .NET timeout documentation warns that increasing the implicit wait can adversely affect runtime, particularly with slower element-location strategies. Avoid combining a large implicit wait with explicit waits without understanding the effects for your driver and test. The documentation does not establish a universal timing formula for the combination. Selenium ITimeouts API
Troubleshoot common wait failures
- The wait times out although the element exists: Check that the locator matches the intended element and that the predicate tests the right state. Presence alone does not imply visibility or readiness for the next action.
- The test fails immediately with an element exception: That exception may not be ignored by the wait. Fix an invalid locator or incorrect test assumption; add a narrow ignored exception only if it is expected to be transient for this condition.
- The test continues before the page is ready: The predicate may be checking only for presence or another state that occurs too early. Wait for the state the application exposes when the desired operation is ready.
- The test is slower than expected: Review the timeout, polling interval, duration of the condition itself, and any implicit wait configured on the driver. Selenium does not promise an exact total elapsed time based solely on the configured timeout.
- The code does not compile with a nullable warning: The object-returning example uses
nullto mean “not ready yet.” Adapt its return annotation to the project’s target framework and nullable-reference-type settings.
Or skip the browser setup
If your goal is a website screenshot rather than a Selenium browser interaction, ScreenshotNeo can return an image or PDF with one GET request. Its clean-shot process accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the page verdict and billing status in headers. It also offers an MCP server for AI agents, including Claude and Cursor.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
For setup and request options, see the ScreenshotNeo documentation. Replace the example URL with the page you want to capture:
Best Value
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for free ScreenshotNeo screenshots.
Frequently Asked Questions
Does WebDriverWait return the element when the wait succeeds?
Yes. If the condition returns a non-null object, Until returns that object; a boolean condition returns its successful result.
Can I use Selenium Expected Conditions in Selenium 4 for C#?
Selenium’s .NET support for Expected Conditions stopped in Selenium 4; use a lambda with Until instead.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →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.




