Selenium Expected Conditions are checks for browser states—such as an element becoming visible or an alert appearing—that you use with an explicit wait. In Python, the basic pattern is WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "exampleId"))). The wait polls until the condition succeeds or times out, and until returns the condition’s result, which may be a WebElement rather than a Boolean.
How an Expected Condition works
An Expected Condition is a callable check of browser state. An explicit wait evaluates it repeatedly until it returns a truthy result or the timeout expires. It is not a standalone delay: unlike time.sleep(), the wait can continue as soon as the requested state is reached.
The Python example below uses Selenium’s documented imports and a ten-second timeout as an illustration, not a universal recommendation. Choose a timeout that fits the operation and test environment.
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
wait = WebDriverWait(driver, timeout=10)
revealed = wait.until(
EC.visibility_of_element_located((By.ID, "revealed"))
)
revealed.send_keys("ready")
Here, until returns the visible WebElement, so the code can act on it. Other conditions return values such as True. until_not waits until a condition returns a falsey result.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Selenium’s guide demonstrates the same approach on a page where a control reveals an element: click the control, wait for visibility_of_element_located, then type into the returned element. See Selenium’s guide to waits and Expected Conditions.
Choose a condition for the state you need
Presence, visibility, and clickability are different checks. Pick the narrowest condition that reflects what the next test action actually needs.
| Need | Python condition | What success means |
|---|---|---|
| Element is attached to the DOM | presence_of_element_located(locator) |
The element exists in the DOM; it may still be hidden. |
| One element is displayed with nonzero dimensions | visibility_of_element_located(locator) |
Returns the element when visible. |
| At least one matching element is visible | visibility_of_any_elements_located(locator) |
Returns the visible matching elements. |
| All matching elements are present or visible | presence_of_all_elements_located(locator) or visibility_of_all_elements_located(locator) |
Use the first for DOM presence and the second for visibility. |
| Text appears in an element | text_to_be_present_in_element(locator, text) |
The displayed element’s text contains the requested text. |
| Element is ready for a click attempt | element_to_be_clickable(locator) |
The element is visible and enabled. This does not guarantee that the application’s action will succeed. |
| Loading element is gone | invisibility_of_element_located(locator) |
Returns true if the element is hidden or absent; a stale reference also counts as no longer visible. |
| Specific old element has been detached | staleness_of(element) |
The particular WebElement is no longer attached to the DOM. |
| Frame is ready to enter | frame_to_be_available_and_switch_to_it(locator) |
On success, switches the driver into the frame. |
| Alert is present | alert_is_present() |
Returns the alert and switches to it. |
| A new window opens | new_window_is_opened(current_handles) |
Detects an increase in the number of window handles. |
| Title or URL reaches a target | title_is, title_contains, url_to_be, url_contains |
Choose exact equality or substring matching deliberately. |
| Several states must all succeed | all_of(...) |
AND-like combination; returns successful results. |
| Any one of several states is acceptable | any_of(...) |
OR-like combination; returns the first successful result. |
| None of several states may hold | none_of(...) |
NOT-OR-like combination. |
The Python API also documents attribute and selection-state checks. Confirm exact names and return behavior in the reference for the Selenium binding and version your project uses: Selenium Python Expected Conditions API.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Use a locator or an existing WebElement?
Locator-based conditions can look up the element again on each poll. This is often useful when a dynamic page replaces an element during a rerender:
Recommended Free Tools
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#results")))
Some conditions also accept a WebElement, so you can check a particular object you already found:
element = driver.find_element(By.ID, "results")
wait.until(EC.visibility_of(element))
The trade-off is that a WebElement refers to that particular element. If the page detaches or replaces it, stale-element behavior can matter; a locator-based check can find the replacement on a later poll. Conditions vary in which forms they support, so check the Python API reference before substituting one argument type for another.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Timeouts, polling, and implicit-wait conflicts
The Python WebDriverWait(driver, timeout, poll_frequency=0.5, ignored_exceptions=None) API describes a timeout in seconds, a default polling interval of half a second, and NoSuchElementException as the default ignored exception. Other exceptions generally propagate unless configured otherwise. A wait ends when its condition returns a truthy value or an unignored exception occurs; if the timeout expires first, it raises TimeoutException. See the Python WebDriverWait API.
Selenium warns that mixing implicit and explicit waits can lead to unpredictable timeout behavior. For tests built around Expected Conditions, prefer explicit waits and avoid setting a nonzero implicit wait unless you have deliberately accounted for the interaction. The general guidance is in Selenium’s waits documentation.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Combine conditions or write a custom predicate
Python’s all_of, any_of, and none_of combine existing conditions when a test accepts multiple states or requires several checks at once. A custom function or lambda is also valid when the built-in conditions do not express the state you need:
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
def results_are_ready(driver):
elements = driver.find_elements(By.CSS_SELECTOR, ".result")
return elements if elements else False
results = wait.until(results_are_ready)
Keep a custom predicate focused on observing browser state. A wait may call it many times; changing application state during evaluation can cause unexpected side effects. Selenium’s Java Expected Condition API notes this concern as well: Java ExpectedConditions API.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Binding and version differences
Expected Conditions are not exposed in the same way in every Selenium language binding. Python and Java document condition APIs. Selenium’s guide says .NET stopped supporting Expected Conditions in Selenium 4 to reduce maintenance and redundancy; Ruby commonly uses blocks, procs, and lambdas instead of condition classes. Do not copy Python imports or condition names into another language without checking its documentation. The official cross-language overview is Selenium’s waits guide.
Common failures and practical fixes
- TimeoutException: The requested state did not become true within the chosen timeout. Check that the locator matches the current page, that the intended action happened, and that the condition asks for the right state—for example, presence instead of visibility if the element is meant to remain hidden.
- Element is present but cannot be used: Presence only confirms DOM attachment. Wait for visibility or clickability when the next action needs those properties.
- StaleElementReferenceException: The page likely replaced the specific element you retained. Use a locator-based condition to re-find it during polling, or reacquire the element after the rerender.
- Click condition succeeds but click fails: Clickability checks visibility and enabled state, not every application-specific obstruction or action outcome. Check overlays, page state, and the target action separately.
- Wait takes longer than expected: Review implicit-wait settings as well as explicit timeout and polling values. Selenium cautions that combining implicit and explicit waits can produce unpredictable timing.
- Condition name or import is unavailable: Confirm the language binding and installed Selenium version. Expected Conditions support and syntax differ among Python, Java, .NET, and Ruby.
Or skip the browser setup
If your goal is a page image rather than an interactive browser test, ScreenshotNeo provides a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF. Its capture flow accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses include X-Page-Verdict and X-Billed headers. AI agents can use its MCP tools, including take_screenshot, get_page_info, and capture_pdf.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsFor example, this cURL request captures a URL to a WebP file:
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for parameters and other output options. ScreenshotNeo offers 1,000 shots per month free with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month, with no card required.
Frequently Asked Questions
Does `until` return a Boolean?
Not always. It returns the successful condition’s result, which may be a WebElement or another value.
Are Expected Conditions available in Selenium .NET and Ruby?
The Selenium guide says .NET stopped supporting them in Selenium 4, while Ruby commonly uses blocks, procs, and lambdas instead of Expected Conditions classes.
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.




