Free tools Windows power users keep installed
One-click scans. No signup required.
First determine whether the page uses a native <input type="date"> or a custom calendar. For a native field, Selenium JavaScript bindings can usually enter an ISO date such as 2026-10-03 with sendKeys, then verify the field’s normalized value. Use executeScript to assign the DOM value only when that is the behavior you intend to test: setting the property does not itself fire the user-originated input event, so it may not update application state. Custom pickers need interactions based on their actual controls.
Identify the date control before choosing a method
Inspect the page’s DOM and determine what the user is actually interacting with. A native date field has a standard value model; a custom calendar is an application-specific widget and may combine visible controls, hidden fields, and framework-managed state.
- Native field: Look for
<input type="date">. Check itsmin,max, andstepattributes, if present. - Custom picker: Inspect the visible input, calendar buttons, day cells, accessible names or roles, and any documented keyboard behavior. There is no universal selector or click sequence for every picker.
For native date inputs, the underlying value is normalized as yyyy-mm-dd, even when the browser displays the date in a localized format. The popup’s appearance and interaction can vary by browser and operating system, so avoid assertions about a particular rendered date string or popup layout across platforms. See MDN’s date input reference.
Use WebDriver interaction for a native date input
Start with Selenium’s normal element interaction. Locate the field with an application-specific selector, send the ISO-formatted date, then read the value back and assert it. Selenium’s high-level interactions check whether an element is visible and interactable; exact keyboard behavior can still depend on the browser and driver, so verify this approach in the project’s target environment. See Selenium’s element interaction guidance and the JavaScript WebElement API.
#1 Best Overall
const { Builder, By } = require('selenium-webdriver');
(async () => {
const driver = await new Builder().forBrowser('chrome').build();
try {
await driver.get('https://example.com/form');
// Replace this selector and date with values for your application.
const dateInput = await driver.findElement(By.css('input[type="date"]'));
await dateInput.sendKeys('2026-10-03');
const value = await dateInput.getAttribute('value');
if (value !== '2026-10-03') {
throw new Error(`Unexpected date value: ${value}`);
}
} finally {
await driver.quit();
}
})();
This is an illustrative JavaScript-binding pattern, not a claim that it has been tested across every browser and driver combination. Use a locator tied to the page under test, choose a date allowed by the field’s constraints, and assert the application outcome as well as the field value when the form has validation or dependent behavior.
Set the value with executeScript only when appropriate
Selenium’s JavaScript API says that executeScript runs a script in the currently selected frame or window, and it can receive a WebElement as an argument. For a simple native input, direct assignment is concise:
Rank #2
const dateInput = await driver.findElement(By.css('input[type="date"]'));
const value = await driver.executeScript((el, date) => {
el.value = date;
return el.value;
}, dateInput, '2026-10-03');
if (value !== '2026-10-03') {
throw new Error(`Unexpected date value: ${value}`);
}
This assertion confirms only the DOM property. Programmatically setting an element’s value does not itself fire the user-originated input event, as MDN documents. Therefore, a framework or application handler may not observe or commit the change. A successful script return does not prove the form will submit the date or that application state has updated. Prefer sendKeys or the widget’s real controls when user-facing event behavior matters, and verify the resulting state. Selenium’s script execution and argument behavior are described in the WebDriver JavaScript API.
Interact with custom calendar widgets through their real controls
For a custom picker, inspect the actual page and use the controls that the component exposes. Depending on the implementation, that may mean entering text, opening a calendar and selecting a day, or following a supported keyboard path. Base the locator and interaction on the component’s markup or documentation rather than assuming a library-specific class or XPath.
- Locate the relevant input or calendar trigger using a stable application selector or accessible name.
- Use the component’s visible controls or documented keyboard behavior to choose the date.
- Verify the displayed selection or input value.
- Check an application-level result, such as updated date-dependent content, a validation message, or an enabled submit control.
The Selenium interactions documentation explains the general element interaction model, but it cannot prescribe a universal custom-picker sequence: Selenium: Interacting with web elements.
Wait for an observable result and validate constraints
After entering or selecting a date, wait for a condition that expresses the outcome you need instead of relying on an arbitrary pause. Depending on the form, that condition could be the expected normalized input value, a validation message, an enabled submit button, or updated date-dependent content.
Rank #4
- Check whether
min,max, orstepmakes the chosen date invalid. - Distinguish a value present in the DOM from a value accepted by application validation.
- If using Selenium’s asynchronous script API, call the callback Selenium supplies as the final argument to signal completion. For ordinary element interactions, use a state-based wait for the expected result.
The native input’s value and constraints are described in MDN’s date input reference; Selenium documents script execution in its JavaScript WebDriver API.
Choose between WebDriver interaction and DOM assignment
| Approach | Best fit | Main limitation | What to assert |
|---|---|---|---|
sendKeys or custom-widget controls |
Tests where user interaction, event handlers, validation, or component state matter | Keyboard entry and native picker behavior may require attention to the target browser and platform | The field value and a meaningful application-level outcome |
executeScript value assignment |
A narrow test where setting a native input’s DOM property is explicitly sufficient | Property assignment alone does not fire the user-originated input event or prove application state changed |
The DOM value, plus application state if the test depends on it |
Troubleshoot common failures
- The value is empty or differs from the expected date: Use the normalized
yyyy-mm-ddvalue for a native date input, and read it back after entry. Confirm that the locator targets the intended field and that the date satisfies its constraints. - The field shows the date, but the application ignores it: A DOM property assignment may not have triggered the event or state update the application expects. Use WebDriver interaction or the widget’s real controls, then verify the resulting application behavior.
- The date cannot be entered with
sendKeys: Confirm that the element is a native date input and is visible and interactable. Test the browser and driver combination used by the project; do not assume the native picker behaves identically on every platform. - A custom calendar selector does not work: Inspect that specific widget’s DOM, accessible controls, and keyboard behavior. A class name or day-cell locator from another picker is not a general solution.
- The script runs in the wrong context or cannot use the element: Ensure the intended frame or window is currently selected before calling
executeScript. Selenium executes the script in the currently selected frame or window. - An asynchronous script never completes: Call the callback supplied to
executeAsyncScript, and wait on an observable state when that better matches the requirement.
Or skip the browser setup
If you need an image or PDF of a page rather than a Selenium interaction test, ScreenshotNeo is a website screenshot API and MCP server. A GET request can return a screenshot or PDF; its clean-capture options accept consent banners and remove known consent platforms, newsletter popups, and chat widgets before capture. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. AI agents can use its MCP server, and the free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
For a one-call screenshot, see the ScreenshotNeo documentation:
Best Value
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
This captures a page; it does not replace Selenium when the test must operate a date picker or assert form behavior. Sign up for 1,000 free screenshots a month, with no card required.
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.




