DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

How to Use Explicit and Fluent Waits in Selenium with C#

A practical C# guide to Selenium explicit waits: write a WebDriverWait predicate, configure polling and exceptions, and avoid unpredictable mixed waits.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use an explicit wait in Selenium C# when your test needs a particular browser condition to become true: create a WebDriverWait with a TimeSpan, then call Until with a predicate. Configure its polling interval or ignored exceptions when the condition warrants it. In .NET, Selenium’s WebDriverWait is the configurable wait; you do not need Java’s FluentWait syntax.

Write an explicit wait with WebDriverWait

An explicit wait repeatedly evaluates a specific condition and continues when it succeeds or stops when the timeout expires. The Selenium guide’s C# dynamic-page example is:

As an Amazon Associate I earn from qualifying purchases.

IWebElement revealed = driver.FindElement(By.Id("revealed"));
driver.FindElement(By.Id("reveal")).Click();

var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(2));
wait.Until(d => revealed.Displayed);

revealed.SendKeys("Displayed");

The predicate passed to Until is checked repeatedly. Here it returns true only when the element is displayed, so the test sends text after the desired state is reached. The two-second timeout is the documentation example, not a universal setting; choose a limit appropriate to the operation and test environment. See Selenium’s Waiting Strategies guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Wait for the state your next step requires

Make the predicate represent the actual condition needed by the next command—for example, visibility before interacting with an element, or expected text before asserting it. A timeout does not make a slow or broken page ready; it means the condition did not become true within the configured limit. Keep the condition specific enough that a successful result really permits the next step.

Configure polling, ignored exceptions, and timeout messages

Selenium’s C# guide demonstrates setting the polling interval and ignoring an exception type:

var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(2))
{
    PollingInterval = TimeSpan.FromMilliseconds(300),
};
wait.IgnoreExceptionTypes(typeof(ElementNotInteractableException));

wait.Until(d =>
{
    revealed.SendKeys("Displayed");
    return true;
});

Configure exception handling carefully. Ignore an exception only when retrying the condition is sensible; otherwise, the wait can hide a genuine failure. The predicate should return success only after the intended state or action has succeeded. In this example, true is returned after SendKeys completes, not before.

The .NET wait API also exposes a timeout message, timeout, polling interval, and ignored-exception configuration. Consult the DefaultWait<T> API and WebDriverWait API for the members available to your installed package.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What “fluent wait” means in Selenium .NET

“Explicit wait” describes waiting for a named condition. “Fluent” commonly describes configuring how a wait behaves, such as its timeout, polling interval, and exceptions to ignore. Selenium’s .NET WebDriverWait derives from DefaultWait<IWebDriver>, and the official C# example configures WebDriverWait directly. Use that .NET API rather than copying Java examples that construct FluentWait or call methods such as withTimeout.

Selenium’s current Expected Conditions page says that .NET stopped supporting its built-in Expected Conditions in Selenium 4 to reduce maintenance and redundancy. Use predicates with Until, as above, unless your project deliberately includes a separately verified library. Details are on Selenium’s Expected Conditions page.

Choose explicit waits over a global implicit wait for dynamic states

Approach How it behaves When it fits
Implicit wait Applies globally to element-location calls for the session. Selenium’s default is zero. It is a broad setting, not a wait for a particular visible state, text, or action.
Explicit wait Polls a predicate at the point where the condition is needed; its timeout, polling, and exception behavior can be configured. Use it for a specific dynamic condition such as an element becoming visible or text appearing.
Fixed sleep Always pauses for the chosen duration and does not check whether the needed state has occurred. Reserve it for a genuinely required fixed pause, not general page readiness.

Avoid combining implicit and explicit waits in one session. Selenium warns that their interaction can make elapsed time unpredictable: its example notes that a 10-second implicit wait combined with a 15-second explicit wait can time out after 20 seconds. Prefer explicit waits for particular dynamic conditions and avoid a competing implicit wait. See the official guidance.

Version and API notes for C#

  • The current Selenium C# wait example uses TimeSpan to set the timeout.
  • A Selenium 4 upgrade page discusses Duration-based wait API changes, but that excerpt does not establish a corresponding .NET API change. Do not infer a C# migration requirement from another language’s API; check the API for your installed .NET package and target version. See Selenium’s Selenium 4 upgrade guide.
  • Built-in Expected Conditions are not supported in .NET Selenium 4; a C# predicate passed to Until is the documented approach.

Troubleshoot waits that time out or finish too soon

  • The wait times out: identify which predicate failed and whether the page reached the expected state. A timeout is a bound, not a guarantee that loading will finish.
  • The next interaction still fails: check that the predicate tests the state required for that interaction and returns success only after that state is present.
  • The delay is longer than expected: look for an implicit wait configured elsewhere in the session; Selenium warns that mixing it with explicit waits produces unpredictable total timing.
  • An exception appears during polling: ignore it only if retrying that condition is appropriate. Otherwise let the failure surface instead of masking it.
  • Expected Conditions examples do not compile: .NET no longer includes Selenium’s built-in Expected Conditions in Selenium 4. Replace them with a predicate or verify the separate dependency your project intends to use.
  • A Java wait example does not compile in C#: use the .NET WebDriverWait API and its TimeSpan example, not Java constructors or method names.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If the goal is a screenshot rather than an interactive Selenium test, ScreenshotNeo offers a screenshot API and MCP server. One GET request can return an image or PDF; consult the API documentation for request options.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Does Selenium C# use a FluentWait class?

The documented .NET pattern configures WebDriverWait, which inherits from DefaultWait<IWebDriver>; do not transfer Java’s FluentWait syntax to C#.

Can I use Selenium Expected Conditions in .NET Selenium 4?

Selenium’s documentation says built-in Expected Conditions are no longer supported in .NET. Use a predicate with Until or verify any separate library you choose.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.