How to Write Test Cases for Date Picker (With Examples)

How to Write Test Cases for Date Picker (With Examples)

March 20, 2026 · 16 min read · How-To Guides

How to Write Test Cases for Date Picker (With Examples)

Date pickers are ubiquitous UI components that allow users to select a single date, a date range, or a date and time. Despite their apparent simplicity, date pickers hide a multitude of implementation details that can cause functional defects, accessibility barriers, and localization failures. Writing effective test cases for a date picker requires a systematic approach that covers normal usage, invalid input, boundary conditions, accessibility, and internationalization. This guide walks you through the anatomy of a test case, provides a concrete matrix of 25+ test cases, shows how to prioritize and trace them to requirements, and explains how combining manual design with autonomous exploration (e.g., using a platform like SUSA) yields real‑world coverage. Each section includes practical examples, code snippets for automation, and a short checklist you can bookmark.

How to Write Test Cases for Date Picker (With Examples): Foundations

Before diving into individual test ideas, it is useful to clarify what makes a date picker testable and why generic UI test advice often falls short. A date picker typically consists of:

Testability hinges on being able to observe the component’s state after each interaction: the displayed value, the underlying model (e.g., a JavaScript Date object), and any side effects such as form validation triggers. When writing test cases, you must consider:

  1. Input modalities – touch, mouse, keyboard, assistive technology.
  2. Data formats – ISO 8601, locale‑specific patterns, timestamps.
  3. State persistence – does the picker close after selection? Does it retain the last opened month?
  4. Error handling – how does the component react to out‑of‑range or malformed values?
  5. Cross‑cutting concerns – accessibility (WCAG 2.1 AA), right‑to‑left layouts, timezone shifts, leap years.

Understanding these dimensions helps you move beyond “click a date and verify it appears” and toward a test suite that catches regressions before they reach production.

How to Write Test Cases for Date Picker (With Examples): Anatomy of a Test Case

A well‑structured test case makes it easy to review, automate, and trace to requirements. The following fields are recommended:

FieldDescription
IDUnique identifier (e.g., DP‑001). Use a prefix that indicates the feature area.
TitleShort, readable summary (e.g., “Select a valid date using the mouse”).
PreconditionsSystem state required before execution (e.g., “Date picker component is rendered on the page with minDate = 2020‑01‑01 and maxDate = 2025‑12‑31”).
StepsNumbered actions performed by the tester or automation script. Include input values and any waits.
Expected ResultObservable outcome after the final step (e.g., “Input field displays ‘2023‑07‑15’ and the underlying model holds a Date object for 2023‑07‑15”).
PostconditionsAny cleanup or state verification needed to leave the system ready for the next test (e.g., “Date picker is closed”).
PriorityTypically P0 (critical), P1 (high), P2 (medium), P3 (low). Based on risk and business impact.
TagsKeywords for filtering (e.g., positive, keyboard, accessibility, locale‑fr).
TraceLink to the requirement or user story (e.g., US‑1234: Date picker must allow selection of any date within the allowed range).

Using this template ensures consistency across manual test sheets, test management tools, and automated test code. When you later convert a manual case to an automated script, you can map each step directly to a command in your test framework.

How to Write Test Cases for Date Picker (With Examples): Positive Test Cases

Positive test cases verify that the date picker behaves correctly when users provide valid input through the supported interaction methods. Below are representative scenarios; you can expand them based on your product’s specific features (e.g., range selection, time‑of‑day).

IDTitlePreconditionsStepsExpected Result
DP‑001Select a date via mouse clickDate picker inline, minDate=2020‑01‑01, maxDate=2025‑12‑31, today=2023‑08‑151. Click the day cell for 2023‑08‑20Input shows “2023‑08‑20”; model date = 2023‑08‑20; picker closes (if modal).
DP‑002Select a date via keyboard navigation (arrow keys)Same as DP‑001, focus on the input field1. Press Alt+Down to open picker
2. Press Right five times to move from today to 2023‑08‑20
3. Press Enter
Input shows “2023‑08‑20”; model updated; picker closes.
DP‑003Type a valid date directly into the input fieldInput accepts manual entry, format yyyy‑MM‑dd1. Click the input field
2. Type 2022‑12‑31
3. Press Tab or click outside
Input shows 2022‑12‑31; model date = 2022‑12‑31; no validation error shown.
DP‑004Select a date range (start and end)Range picker enabled, minDate=2020‑01‑01, maxDate=2025‑12‑311. Click start date 2023‑09‑01
2. Click end date 2023‑09‑10
Input shows “2023‑09‑01 – 2023‑09‑10”; model contains start=2023‑09‑01, end=2023‑09‑10.
DP‑005Clear the selected date using the clear buttonA date is already selected (e.g., 2023‑07‑15)1. Click the clear (×) button inside the picker or input fieldInput becomes empty; model date = null; any dependent validation messages disappear.
DP‑006Navigate months using the next/prev arrowsPicker opened, displaying August 20231. Click the “Next month” arrow twice
2. Observe month header
Month header changes to October 2023; day grid updates accordingly; selected date (if any) stays unchanged.
DP‑007Jump to a specific year via year dropdownPicker opened, year dropdown visible1. Click the year dropdown
2. Select 2021
3. Verify month grid
Month grid shows January 2021; navigation respects the new year.
DP‑008Select today using the “Today” shortcut buttonPicker opened, today button present1. Click the “Today” buttonInput shows today’s date (2023‑08‑15); model updated; picker closes.
DP‑009Select a date via swipe gesture on touch deviceTouch‑enabled device, picker displayed as a modal1. Swipe left on the month header to go to September 2023
2. Tap day 15
Input shows 2023‑09‑15; model updated; picker closes.
DP‑010Validate that selecting a date updates a bound form fieldForm with a date field bound to the picker via v-model (Vue) or useState (React)1. Choose 2024‑02‑10 in the pickerBound form field reflects 2024‑02‑10; any form‑level validation runs without error.

These ten cases already cover mouse, keyboard, direct entry, range, clear, navigation, shortcuts, touch, and framework binding. Feel free to add variations for time selection (hour/minute spinners) or for disabling specific weekdays.

How to Write Test Cases for Date Picker (With Examples): Negative and Invalid Input Cases

Negative test cases ensure the component gracefully handles data that should not be accepted. The goal is to verify that invalid input does not corrupt the model, does not crash the component, and provides clear feedback to the user.

IDTitlePreconditionsStepsExpected Result
DP‑011Enter a date before the minimum allowed dateminDate=2020‑01‑01, maxDate=2025‑12‑311. Click input
2. Type 2019‑12‑31
3. Press Tab
Input shows an error (e.g., red border, tooltip “Date must be on or after 2020‑01‑01”); model remains unchanged (still at previous valid value or null.
DP‑012Enter a date after the maximum allowed dateSame as DP‑0111. Type 2026‑01‑01
2. Press Tab
Same validation error as DP‑011, but with upper bound message.
DP‑013Enter a non‑date string (letters)Input accepts manual entry1. Type abcd
2. Press Tab
Input shows validation error “Please enter a valid date”; model unchanged.
DP‑014Enter a date with wrong separator (e.g., slash)Expected format yyyy‑MM‑dd1. Type 2023/08/15
2. Press Tab
Depending on implementation: either auto‑correct to 2023‑08‑15 or show error “Invalid format”.
DP‑015Enter a date with missing leading zerosFormat expects two‑digit month/day1. Type 2023‑8‑5
2. Press Tab
Either auto‑pads to 2023‑08‑05 or shows format error.
DP‑016Enter a date that is not a real calendar date (e.g., Feb 30)Input accepts manual entry1. Type 2023‑02‑30
2. Press Tab
Validation error “Invalid date”; model unchanged.
DP‑017Attempt to select a disabled date in the gridCertain dates are disabled (e.g., weekends, holidays)1. Open picker
2. Try to click a disabled cell (e.g., a Saturday)
Click is ignored; selected date does not change; no error message needed (just no action).
DP‑018Open picker and press Escape to cancel without selectionPicker opened, a date may be pre‑selected1. Press EscPicker closes; input retains any previously selected date (or remains empty if none).
DP‑019Paste a malformed date from clipboardInput field supports paste1. Copy string not-a-date
2. Focus input
3. Paste (Ctrl+V)
Input shows validation error; model unchanged.
DP‑020Rapidly toggle month navigation causing UI glitchPicker opened, fast clicking allowed1. Repeatedly click next/previous month arrows 10 times within 1 secondCalendar updates correctly each time; no duplicate month headers, no missing days, no JS errors in console.

These cases probe boundary validation, format enforcement, disabled state handling, and interaction robustness. When automating, you can assert that the component’s error state (e.g., aria-invalid="true") appears and that the model value does not change.

How to Write Test Cases for Date Picker (With Examples): Boundary and Edge Cases

Boundary testing focuses on values at the limits of accepted ranges, as well as special calendar quirks like leap years, month transitions, and timezone shifts. Edge cases often involve uncommon user behaviors or device conditions that surface only in production.

IDTitlePreconditionsStepsExpected Result
DP‑021Select the minimum allowed dateminDate=2020‑01‑01, maxDate=2025‑12‑311. Open picker
2. Navigate to January 2020
3. Click day 1
Input shows 2020‑01‑01; model updated; picker closes.
DP‑022Select the maximum allowed dateSame as DP‑0211. Navigate to December 2025
2. Click day 31
Input shows 2025‑12‑31; model updated; picker closes.
DP‑023Select February 29 on a leap yearminDate=2020‑01‑01, maxDate=2028‑12‑31 (includes 2024‑02‑29)1. Navigate to February 2024
2. Click day 29
Input shows 2024‑02‑29; model updated; no error.
DP‑024Attempt to select February 29 on a non‑leap yearSame range, but year 2023 is not a leap year1. Navigate to February 2023
2. Try to click day 29
Day 29 is either hidden or disabled; clicking does nothing; model unchanged.
DP‑025Select date after crossing year boundary via fast‑forwardPicker opened showing December 20231. Click the year dropdown
2. Choose 2025
3. Click day 15
Input shows 2025‑01‑15 (if month stayed January) or 2025‑12‑15 depending on implementation; model updated correctly.
DP‑026Change system timezone while picker is openPicker displaying a date; user’s timezone set to UTC1. Change OS timezone to UTC+5
2. Observe picker display
Displayed dates adjust to reflect the new offset if the component uses local time; otherwise, dates stay same but underlying UTC value shifts.
DP‑027Select a date when the device locale uses a different calendar (e.g., Persian)Locale set to fa-IR (Persian calendar)1. Open picker
2. Observe that grid shows Persian months/days
3. Select a date
Selected date is correctly converted to Gregorian for the model (e.g., selecting 1 Farvardin 1402 yields 2023‑03‑21).
DP‑028Test with font size scaling (200%) for accessibilityBrowser/OS set to 200% text scaling1. Open picker
2. Verify that all touch targets are at least 48 dp
All day cells, navigation arrows, and buttons are easily tappable; no clipping or overlap.
DP‑029Simulate a slow network while loading month data via AJAXPicker loads month data lazily from an API1. Throttle network to 50 kbps
2. Open picker
3. Navigate to next month
A loading indicator appears; once data loads, the grid shows correct days; no UI freeze or duplicate requests.
DP‑030Perform a long press on a day cell to trigger a context menu (if supported)Picker supports long‑press for “add note”1. Long‑press on day 10Context menu appears with appropriate actions; selecting an action does not change the selected date unless intended.

These cases push the component to its limits and verify correct handling of calendar peculiarities, accessibility scaling, locale‑specific calendars, and asynchronous data loading. Documenting the expected behavior for each edge case prevents regressions when the underlying date‑handling library is upgraded.

How to Write Test Cases for Date Picker (With Examples): Accessibility and Internationalization Tests

Accessibility (a11y) and localization (i18n) are not optional extras; they are integral to a usable date picker. WCAG 2.1 AA success criteria that apply include keyboard operability, label association, sufficient contrast, and error identification. Internationalization covers locale‑specific formats, right‑to‑left (RTL) layouts, and calendar systems.

IDTitlePreconditionsStepsExpected Result
DP‑031Verify that each day cell has an accessible namePicker opened, inspect DOM1. Use axe or manual inspection to check aria-label or aria-labelledby on a day cell (e.g., day 15)aria-label contains a readable date string, e.g., “August 15, 2023”.
DP‑032Ensure keyboard focus order is logicalFocus on the input field1. Press Tab to move focus into the picker
2. Press Tab repeatedly to traverse day cells, navigation buttons, OK/Cancel
Focus moves predictably left‑to‑right, top‑to‑bottom (or RTL equivalent) without jumps or traps.
DP‑033Check contrast of selected day backgroundSelected day styled with a background color1. Use a contrast analyzer on the selected day cell vs. its background textContrast ratio ≥ 4.5:1 for AA text (or ≥ 3:1 for large text).
DP‑034Validate error message is announced by screen readersInput shows validation error after entering an invalid date1. Run a screen reader (NVDA, VoiceOver)
2. Focus the input
Screen reader reads the error message (e.g., “Invalid date. Please enter a date between Jan 1 2020 and Dec 31 2025”).
DP‑035Test date picker in a right‑to‑left locale (e.g., Arabic)Locale set to ar-SA, direction rtl1. Open picker
2. Observe layout
Month navigation arrows are mirrored; day grid starts on the right side; input text aligns right.
DP‑036Verify localized date format matches locale preferencesLocale fr-FR expects dd/MM/yyyy1. Select a date
2. Read the input field
Input displays 15/08/2023 (or the pattern defined for fr-FR).
DP‑037Ensure that the picker works with zoom level 400%Browser zoom set to 400%1. Open picker
2. Interact with all controls
All controls remain visible, usable, and not clipped; no horizontal scrolling required to reach essential elements.
DP‑038Check that date value is correctly announced when using voice inputVoice control software active1. Say “Select August fifteenth twenty twenty‑three”Picker opens, navigates to August 2023, selects day 15, and closes; the transcribed text matches the selected date.
DP‑039Validate that disabling the picker removes it from the tab orderPicker has a disabled attribute1. Tab through the formDisabled picker is skipped; focus moves to the next focusable element.
DP‑040Test that date range selection conveys both start and end to assistive techRange picker with aria-label on the input1. Choose start 2023‑09‑01 and end 2023‑09‑10Screen reader reads something like “From September 1, 2023 to September 10, 2023”.

Incorporating these checks early prevents costly redesigns later. Automated a11y tools (axe, pa11y, @testing-library/jest-dom) can catch many of these issues in CI, while manual screen‑reader testing validates the experience.

How to Write Test Cases for Date Picker (With Examples): Test Data Preparation and Prioritization

Even the best‑designed test suite can become unwieldy if test data is not managed systematically. For date pickers, data preparation involves defining valid ranges, invalid values, locale strings, and timezone offsets. Prioritization helps you focus on high‑risk areas first, especially when time is limited.

Data‑Driven Approach

Create a JSON or CSV file that feeds both manual test scripts and automated tests. Example snippet:


{
  "valid": [
    {"value":"2023-01-01","description":"min boundary"},
    {"value":"2023-06-15","description":"mid‑year"},
    {"value":"2025-12-31","description":"max boundary"}
  ],
  "invalid": [
    {"value":"2019-12-31","reason":"below min"},
    {"value":"2026-01-01","reason":"above max"},
    {"value":"2023-02-30","reason":"non‑existent date"},
    {"value":"not-a-date","reason":"wrong format"}
  ],
  "locales": [
    {"code":"en-US","format":"MM/dd/yyyy"},
    {"code":"fr-FR","format":"dd/MM/yyyy"},
    {"code":"ja-JP","format":"yyyy/MM/dd"}
  ]
}

Automated tests can loop over these entries, drastically reducing duplication.

Risk‑Based Prioritization

Use a simple 2‑dimensional matrix: Impact (how severe a defect would be) vs. Likelihood (how probable the defect is to occur). Assign each test case a score (e.g., Impact 1‑3, Likelihood 1‑3) and compute Priority = Impact × Likelihood. Higher scores get P0/P1.

Test IDImpact (1‑3)Likelihood (1‑3)ScorePriority
DP‑001339P0
DP‑011326P1
DP‑023224P2
DP‑031313P2
DP‑040212P3

In practice, you would involve product owners, developers, and support staff to agree on impact levels (e.g., data loss, security, compliance). Likelihood can be informed by historical defect data or by the complexity of the code path.

Traceability to Requirements

Link each test case to a requirement ID in your tracking system (Jira, Azure DevOps, etc.). This enables impact analysis when a requirement changes. Example traceability matrix:

Requirement IDDescriptionCovered Test IDs
REQ‑DATE‑01User can select any date within allowed rangeDP‑001, DP‑002, DP‑003, DP‑021, DP‑022
REQ‑DATE‑02Invalid input shows clear error messageDP‑011, DP‑012, DP‑013, DP‑014, DP‑015, DP‑016, DP‑019
REQ‑DATE‑03Picker is navigable via keyboardDP‑002, DP‑032
REQ‑DATE‑04Picker respects locale-specific formatDP‑036, DP‑035
REQ‑DATE‑05Picker is WCAG AA compliantDP‑031, DP‑033, DP‑034, DP‑037, DP‑038

Maintaining this matrix in a spreadsheet or as markdown in your repo ensures that no requirement slips through the cracks.

How to Write Test Cases for Date Picker (With Examples): Combining Manual Design with Autonomous Exploration

Manual test case design excels at targeting known risks and verifying specific requirements. Autonomous exploration complements this by exercising the component in ways that a human might not think of, uncovering issues that only appear under varied user behaviors, device states, or long‑running sessions.

How Autonomous Platforms Like SUSA Augment Coverage

SUSA (SUSATest) is an autonomous QA agent that, given an APK or a web URL, explores the application using a set of simulated user personas. Each persona has distinct behavior patterns:

When you point SUSA at a web page containing your date picker, it will:

  1. Discover all reachable states – open the picker, navigate months, try direct entry, attempt to paste, etc., without any pre‑written script.
  2. Apply persona‑specific heuristics – the Adversarial persona will try to submit 2023-02-30 or paste JavaScript snippets; the Impatient persona will spam the next‑month button 50 times in a second.
  3. Detect observable failures – crashes, ANRs (for Android), dead buttons, validation messages that do not appear, accessibility violations (missing aria-label, insufficient contrast), and unexpected navigation (e.g., picker closes unexpectedly).
  4. Generate regression scripts – after a run, SUSA outputs Appium (Android) or Playwright (Web) scripts that reproduce the discovered flows, enabling you to add them to your CI pipeline.

Example: Cross‑Session Learning in Practice

Suppose your date picker disables weekends. During the first SUSA run, the Curious persona repeatedly taps on Saturday and Sunday cells, observes that nothing happens, and logs those interactions as “no‑effect”. On a subsequent run, SUSA remembers that Saturday/Sunday taps are ineffective and shifts focus to trying to enable those dates via the URL query param (if your picker supports a disabledDates parameter). If the implementation incorrectly enables a disabled date when a certain query string is present, SUSA will flag it as a defect.

This learning loop means that over time the agent runs, the test suite evolves from a static set of cases to a living specification that adapts to new code paths and edge conditions you may not have anticipated.

Practical Steps to Combine Both Approaches

  1. Start with your manual test matrix (the tables above) as your baseline.
  2. Run SUSA in discovery mode on a staging build. Export the generated Appium/Playwright scripts.
  3. Review the scripts – they often represent realistic user flows that you can convert into additional manual test cases (e.g., “Rapidly toggle month while the picker is loading data via AJAX”).
  4. Add the new cases to your test management tool, prioritize them using the risk matrix, and link them to requirements.
  5. **Integrate the scripts

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free