Hello Folks,

We have seen Handling of calendar of one type in last post.

Adding to it, in this post we will see handling of calendar which has year and month as drop-downs.

A calendar which has year and month has drop-downs looks as below:

User needs to select year followed by month and day. This type of calendar is mostly used across applications as it provides a broader range. This calendar can be used to take input for date of birth etc.

Let’s see how can we handle this type of calendar in Selenium.




Logic:

  1. You must be aware how to handle drop-downs in selenium. If not, don’t worry. Refer below posts:

Handling Any Types Of Listbox/dropdown In Selenium Webdriver

Part 2: Handling Single Select Drop-down Created Using SELECT Tag

Part 3: Handling Multi Select Drop-down Created Using SELECT Tag

Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

  • You need to select desire year first from drop down.
  • You need to wait till months are loaded in month’s drop down.
  • Select desire month from month drop down.
  • Now select desired day from calendar.

Java Code:

Output:

Selected Date: 09/23/2018

Note:

  • You can customize above logic as per your requirement.
  • You can create a reusable method to select date.
  • You can also add some validation if desired year/month/day is not valid/available.

Hope above must must have helped you.

If you have any doubt, feel free to ask here.

If you like my posts, please like, comment, share and subscribe.

#ThanksForReading

#HappySelenium




One thought on “Handling Calendar Which Has Year & Month As Drop down In Selenium

Leave a Reply