Well it is a Cucumber WebDriver in Java
Here is the below code
@And("^I enter my Return Dates as \"([^\"]*)\" days from today date$")
public void i_enter_my_Return_Dates_as_days_from_today_s_date(int duration) throws ParseException {
homescreenpage().enterReturnDate(duration);
}
public void enterReturnDate(int duration) throws ParseException {
Calendar rightNow = Calendar.getInstance();
rightNow.add(Calendar.DAY_OF_MONTH, duration);
day = rightNow.get(Calendar.DAY_OF_MONTH);
month = rightNow.get(Calendar.MONTH);
year = rightNow.get(Calendar.YEAR);
String StringHomePagereturndate = day + "/" + (month + 1) + "/" + year;
HomePagereturndate = StringToDate(StringHomePagereturndate);
travelMonth = months[month] + " " + year;
waitForElementVisible(ReturnDate, 5);
click(ReturnDate);
selectMonth(travelMonth);
selectDay(travelMonth, day);
}
public void selectMonth(String monthtobeSelected) {
/*
* Checking whether the Month and year we are going to select is same as
* what is calculated
*/
// System.out.println(getText(HomePage.xpathMonthYearSection));
while (!getText(xpathMonthYearSection)
.equals(monthtobeSelected)) { /*
* Keep executing untill month
* and year is not same as Month
* and year is calculated
*/
if (getText(xpathMonthYearRightSection).contains(months[month])
&& getText(xpathMonthYearSection).contains(String.valueOf(year))) {
returnTable = 2;
break;
} else {
returnTable = 1;
click(forwardArrow);/*
* Keep clicking the forward button untill
* selected month and year is not appeared
*/
}
}
}
public static String getText(By selector) {
waitUntillElementIsLocated(selector, 10);
return find(selector).getText();
}
Hope you can follow it otherwise I am happy to explain this.
Thank you
Anand Jois