To select a date from date picker | Selenium Forum
M
Posted on 30/09/2015
Hi,
i want a help in selecting the from and return date from the date picker.
i tried in may ways. but i could select the date from the date picker.
Help me in it.
TIA,
nithya.

M
Replied on 01/10/2015

every date picker format is not the same but try this


[quote:2a4d4ame]
DateFormat dateFormat2 = new SimpleDateFormat("dd");
Date date2 = new Date();

String today = dateFormat2.format(date2);

//find the calendar
WebElement dateWidget = driver.findElement(By.id("dp-calendar"));
List<WebElement> columns=dateWidget.findElements(By.tagName("td"));

//comparing the text of cell with today's date and clicking it.
for (WebElement cell : columns)
{
if (cell.getText().equals(today))
{
cell.click();
break;
}
}[/quote:2a4d4ame]


M
Replied on 02/10/2015

Hi,
I m using the date picker of "https://www.cathaypacific.com".
the code which u have given works only for today's date.
i want to select any from and return date.
Please help me on it.


M
Replied on 03/10/2015

for that I think you have to use actions class.
but I don't have any working code for that.