Select the Date from DatePicker in Selenium WebDriver-Example for While loop

In this example we will discuss how to automate the
Date Picker in Selenium WebDriver.
This example also gives details about
the usage of while loop.As we know for and while loop looks
similar in objective. But while loop, helps to execute the
block only when the condition is true.

Difference between for loop and while loop
The for loop is used when you know how many times to execute the block of statements.
In the case of while loop when you are unsure how many iterations are required to
complete the given expression.

The datepicker is tied to a standard form input field. Focus on the input (click, or use the tab key) to open an interactive calendar in a small overlay. Select the date it will display in the input text box.

Real Time DatePicker Example
1. Access the Clear trip website using the following url:
2. Identify the Input Text box.
3. Provide the Future Date to select the Departs on.

Selenium WebDriver Program

Test your Knowledge in Java,Selenium,HTML,QTP,CSS by attending Quiz!!!!
Quiz Link

1 comment on “Select the Date from DatePicker in Selenium WebDriver-Example for While loop

  1. Jumi

    I have one question.even I am trying to code logic for selecting a particular date from date picker in Cleartrip .when I search xpath for month year header ,it comes more than one element as there are 2 months displayed once date picker this case, we need to store month n year element as a list n then forloop to match month n year .again even after using forloop , if it does not match month year , then only we need to click on next to display next 2months .can you please advise if this is correct way??


Leave a Reply

Your email address will not be published. Required fields are marked *