Select a date in a DatePicker with Selenium WebDriver

How to use Selenium WebDriver to select a date in a date picker

Zhimin Zhan

--

A repost of my daughter’s article with permission. I added a few notes. This is also included in my “How to in Selenium WebDriver” series.

Many modern websites use date pickers to select dates. This article will show you how to use Selenium WebDriver to select a date via a date picker in an automated test script. I will script using raw Selenium WebDriver in RSpec, using TestWise IDE.

For some date-pickers, we may be able to set the selected date (the hidden text field) directly, or use JavaScript. In this exercise, I will drive the data-picker UI (as a user would) using Selenium.

· Test Case 1: Select tomorrow’s date (Simple)
Test Design
Prepare
Tasks
·
Test Case 2: Select tomorrow’s date (edge cases)
·
Complete Test Script
·
Zhimin’s Review

Test Case 1: Select tomorrow’s date (Simple)

Test Page URL: https://fengyuanchen.github.io/datepicker/

Test Design

--

--

Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.