I am trying to create a method to click particular date, based on the month and year (I want to pass only date, month and year in the method as parameter).
Also I searched over internet but I didn't get the solution for my query.
Below are the my approach and my testing sample application url.
URL I used: http://www.cleartrip.com/
My Approach:
public static WebElement selectDatefromMultiDate(WebDriver driver, String date, String year,String month) throws IOException, InterruptedException {
driver.findElement(By.id("DepartDate")).click();
WebElement dates = driver.findElement(By.className("ui-state-default"));
List<WebElement> day=dates.findElements(By.tagName("a"));
String calMonth = driver.findElement(By.className("ui-datepicker-month")).getText();
System.out.println(calMonth);
String calYear = driver.findElement(By.className("ui-datepicker-year")).getText();
System.out.println(calYear);
for (WebElement cell: day){
if(calYear.equalsIgnoreCase(year)){
if (calMonth.equalsIgnoreCase(month)){
if (cell.getText().equals(date)){
cell.findElement(By.linkText(date)).click();
}
}
break;
}
}
return element;
}