If Selenium cannot identify or click a datepicker element, first confirm that your locator strategy matches its syntax, then inspect the live DOM after opening the picker. Datepicker popups may be hidden, rendered on demand, duplicated in the page, or rebuilt when the month changes. Locate the active calendar, wait for the state you need, and find elements again after each DOM update.
Start with the exact WebDriver error
Record the exception and the action immediately before it. Different errors point to different failure modes; changing XPath syntax will not fix a stale element, and adding a wait will not fix an invalid selector.
| Exception or symptom | What it usually means | First check |
|---|---|---|
NoSuchElementException |
No matching element was available in the current DOM and browsing context when Selenium searched. | Was the popup opened? Is the element in an iframe or another window? Is the locator aimed at the active calendar? |
InvalidSelectorException |
The selector is malformed or its syntax does not match the locator strategy. | Check whether CSS was passed as CSS and XPath as XPath. |
StaleElementReferenceException |
The WebElement refers to a DOM node that was removed or replaced. | Did opening the picker or changing months rebuild its contents? Locate the element again. |
ElementNotInteractableException |
The element exists but is not currently in a usable state for the requested action. | Check visibility, disabled state, viewport position, and whether the intended element is a hidden duplicate. |
| Click intercepted | Another element, such as an overlay, is receiving the click. | Inspect what covers the target, then wait for it to disappear or use the correct control. |
Selenium notes that an element may not be found “at the exact moment you attempted to locate it.” Its common-errors guidance also cautions that CSS or XPath selectors can be difficult to get right: Selenium: Understanding Common Errors.
Inspect the rendered datepicker, not a guessed selector
Open the page in the same browser and state as the failing test. In developer tools, inspect the input, popup container, month controls, and day cells after the picker is visible. Many datepickers render the popup only when the input is focused or clicked; others keep hidden templates or multiple calendar grids in the DOM.
Recommended Free Tools
#1 Best Overall
- KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
- EASY SETUP: Experience simple installation with the USB wired connection
- VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
- SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
- FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.
- Reproduce the test failure and note the exact exception and preceding action.
- Open the datepicker using the same trigger the test uses.
- Inspect the live input and the visible popup. Identify stable attributes such as a unique id, role, accessible label, or date value.
- Check whether there are multiple matching inputs or day cells, including hidden elements and dates from adjacent months.
- Test the candidate locator against the active widget, not against an absolute XPath copied before the popup rendered.
The correct locator depends on the application’s actual HTML, JavaScript widget, accessibility attributes, and browsing context. The patterns below are examples to adapt and validate, not universal datepicker selectors.
Match locator syntax to Selenium’s strategy
CSS selector syntax belongs with a CSS selector strategy; XPath syntax belongs with XPath. A strategy mismatch commonly produces an invalid selector or a locator that never matches. Selenium supports locator strategies including id, name, CSS selector, XPath, class name, tag name, link text, and partial link text.
| What you have | Example | Use with | Best fit |
|---|---|---|---|
| Stable unique id | departureDate |
By.ID |
A uniquely identified input whose id remains stable. |
| CSS expression | .datepicker[aria-hidden='false'] input |
By.CSS_SELECTOR |
A concise selector scoped by reliable state attributes. |
| XPath expression | //div[@role='dialog' and not(@aria-hidden='true')]//button[@aria-label='Next month'] |
By.XPATH |
Relationships or accessible attributes that are easier to express relationally. |
Selenium’s locator guidance says, “If unique IDs are unavailable, a well-written CSS selector is the preferred method of locating the element.” See Selenium: Tips on working with locators. Prefer the simplest stable locator that identifies exactly the intended control; use XPath when the relevant relationship or accessible text makes it clearer.
Rank #2
- Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
- Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
- Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
- Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
- Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites
Scope the search to the active calendar
A selector for a day such as “button with text 12” can match more than one element: a hidden calendar, a previous-month trailing date, or a next-month leading date. First locate the open calendar container using an attribute that actually changes with its state, then find the target within that container.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11By.CSS_SELECTOR, ".datepicker[aria-hidden='false'] input"
By.XPATH, "//div[@role='dialog' and not(@aria-hidden='true')]//button[@aria-label='Next month']"
If the site exposes a date attribute on a day cell or an accessible label containing the full date, prefer that to a bare day number. If it does not, scope the day locator to the active calendar and confirm whether the cell belongs to the displayed month.
Wait for the state required by the next action
Finding an element and being able to click it are different conditions. Wait for presence when you only need to know it entered the DOM, visibility when the user-facing popup or target must be shown, and clickability when the next step is an interaction. Use an explicit wait after opening the datepicker, because the popup may be rendered asynchronously.
Rank #3
- All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
- Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
- Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
- Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
- Plastic parts in K120 include 51% certified post-consumer recycled plastic*
Selenium’s waiting guidance says the default implicit wait is 0, so a missing element fails immediately, and warns: “Do not mix implicit and explicit waits.” Choose an explicit-wait approach for dynamic datepicker state rather than combining wait styles unpredictably. See Selenium: Waiting Strategies.
Python example
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# Assume the driver is configured for the target browser and the page is open.
wait = WebDriverWait(driver, 10)
# Stable, unique input id (adapt to the application's actual DOM).
date_input = wait.until(
EC.element_to_be_clickable((By.ID, "departureDate"))
)
date_input.click()
# Wait for the active popup to become visible.
calendar = wait.until(
EC.visibility_of_element_located(
(By.CSS_SELECTOR, ".datepicker[aria-hidden='false']")
)
)
# Find the target inside the active calendar. Use the site's real date attribute.
day = calendar.find_element(
By.CSS_SELECTOR, "[data-date='2026-10-15']"
)
wait.until(EC.element_to_be_clickable(
(By.CSS_SELECTOR, ".datepicker[aria-hidden='false'] [data-date='2026-10-15']")
)).click()
The example assumes the page really uses the shown id, active-state attribute, and data-date value; inspect and substitute the attributes in your application. The redundant local day lookup can be omitted if using the final explicit-wait locator directly. Keep the locator and expected condition aligned with the action: visibility is useful for inspecting a rendered popup, while clickability is appropriate before clicking.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Re-find elements after the calendar changes
Changing the month often replaces the grid rather than updating the same nodes. A stored WebElement for the month label, navigation button, or day cell can therefore go stale. Keep locator descriptions, not long-lived element references, across state changes. After every month navigation or range update, wait for the new state and locate the relevant elements again.
Rank #4
- 【Dreamy Rainbow Gaming Keyboard】K521 Gaming Keyboard Adopts a Different LED Backlight Design, Upgraded on the Traditional LED Backlight Effect, Making the Light More Penetrating, Giving You a More Dazzling Visual Effect, Making Your Gaming Process More Enjoyable
- 【One Touch Opens & Visual Feast】The K521 Red Dragon Keyboard has a One-Touch on/off Lighting Button for Added Convenience. It also has a Three-Position Adjustable Breathing Mode and a Four-Position Adjustable Brightness Lighting Mode
- 【Mechanical Feeling & Fast Tapping】The PC Keyboard Keys are Designed for Mechanical Feeling, Giving You a Better Feel During Use and the Ability to Trigger Keys Quickly, Allowing You to Win All Your Games
- 【19 Keys Anti-Ghosting Keyboard】Anti-Ghosting Ensures Every Button Can Be Triggered. This Allows You to Trigger Key Combinations In The Game Accurately, And Each Skill Can Be Accurately Released to Increase Your Winning Rate. Redragon K521 Will Be Your Perfect Partner
- 【12 Multimedia Combination Keys】The K521 Wired Gaming Keyboard is Equipped with 12 Multimedia Keys That Can Greatly Enhance Your Gaming/Office Efficiency and Make It More Convenient to Use
- Locate and click the next/previous-month control in the currently visible calendar.
- Wait for the displayed month label or another reliable state marker to show the requested month.
- Re-find the target day within the active calendar.
- Click only after verifying it is enabled and belongs to the intended month.
Avoid retrying a stale click on the old WebElement. Reacquire it from the current DOM; otherwise, a retry may target a removed node again or an unintended duplicate.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Check frames, windows, overlays, and visibility
Selenium searches the current browsing context. If the date control is inside an iframe, switch to that frame before locating it; if the picker opens a new window, switch to that window. When the control is found but not clickable, inspect its visibility, disabled state, position, and any overlay covering it. Scroll into view only after confirming that the located element is the intended visible control.
Do not treat JavaScript clicks or broad sleeps as the first fix. They can mask a wrong locator, hidden duplicate, or overlay and make a test pass without exercising the user-visible interaction. Correct the context and wait condition first.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Best Value
- All-day Comfort: This USB keyboard creates a comfortable and familiar typing experience thanks to the deep-profile keys and standard full-size layout with all F-keys, number pad and arrow keys
- Built to Last: The spill-proof (2) design and durable print characters keep you on track for years to come despite any on-the-job mishaps; it’s a reliable partner for your desk at home, or at work
- Long-lasting Battery Life: A 24-month battery life (4) means you can go for 2 years without the hassle of changing batteries of your wireless full-size keyboard
- Simply plug the USB receiver into a USB port on your desktop, laptop or netbook computer and start using the keyboard right away without any software installation
- Simply Wireless: Forget about drop-outs and delays thanks to a strong, reliable wireless connection with up to 33 ft range (5); K270 is compatible with Windows 7, 8, 10 or later
Choose a locator that will survive ordinary UI changes
| Locator approach | Uniqueness and scope | Change resistance | Readability and maintenance |
|---|---|---|---|
| Unique stable id | Strong when genuinely unique. | Usually good if the application treats the id as stable. | Shortest and easiest to review. |
| Scoped CSS | Good when scoped to the active widget and state attributes are reliable. | Good when based on meaningful attributes rather than styling classes. | Concise and broadly familiar across Selenium bindings. |
| Relative XPath | Can express relationships and accessible text within the open dialog. | Depends on how stable the relationship and attributes are. | Useful for relational markup, but complex expressions can be harder to debug. |
In all cases, verify that the locator returns the intended element and not a hidden duplicate. Avoid absolute paths tied to incidental DOM nesting: a minor markup change can invalidate them without changing the datepicker’s behavior.
Troubleshoot common failure patterns
The input is found, but the popup is not
- Likely cause: The popup is created only after focus or click, or the wait begins before the triggering action.
- Fix: Trigger the picker first, then explicitly wait for the visible popup or target cell.
The selector works in developer tools but not in Selenium
- Likely cause: The test is in a different frame or window, or the DOM changed between inspection and lookup.
- Fix: Reproduce in the test’s browsing context, switch to the correct frame/window, and inspect again after opening the picker.
The test selects the wrong day
- Likely cause: A bare day number matches a duplicate or an adjacent-month cell.
- Fix: Scope to the active calendar and prefer a full-date attribute or accessible label; verify month membership.
The locator becomes stale after navigation
- Likely cause: The widget rebuilt its grid or replaced the popup DOM.
- Fix: Wait for the updated month state and reacquire the month label and day cell before interacting.
The element is visible but the click fails
- Likely cause: An overlay intercepts the click, the cell is disabled, or the element is outside the usable viewport.
- Fix: Inspect the covering element and target state, wait for overlays to clear, and scroll the verified target into view if needed.
The selector fails immediately
- Likely cause: Invalid syntax or a selector passed with the wrong locator strategy.
- Fix: Pair CSS with
By.CSS_SELECTORand XPath withBy.XPATH, then validate the expression against the rendered DOM.
Or skip the browser setup
If your task is to capture a visual reference of the datepicker page rather than automate its interaction, ScreenshotNeo can return a screenshot or PDF from one GET request. It is a website screenshot API and MCP server for developers: ScreenshotNeo.
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. This captures a page; it does not replace Selenium’s date-selection interaction.
- Cookie and consent banners are accepted like a visitor and removed, along with supported newsletter popups and chat widgets; each cleanup step can be turned off.
- Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; responses include
X-Page-VerdictandX-Billedheaders. - An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for AI agents and MCP clients. - The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
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.

