Note- 1st click on the calendar button then click on the date which you want to select.
Here in the below example, it will always select the current date , you can pass any date which you want to select as per your requirement.
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TodayDate {
public static void main(String[] args) {
int day, month, year;
GregorianCalendar date = new GregorianCalendar();
day = date.get(Calendar.DAY_OF_MONTH);
month = date.get(Calendar.MONTH)+1;
year = date.get(Calendar.YEAR);
String today = "a_"+year+"_"+month+"_"+day;
System.out.println(today);
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("http://www.yatra.com/");
driver.findElement(By.id("BE_flight_depart_date")).click();
driver.findElement(By.xpath("//a[@id='"+today+"']")).click();
}
}
Here in the below example, it will always select the current date , you can pass any date which you want to select as per your requirement.
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TodayDate {
public static void main(String[] args) {
int day, month, year;
GregorianCalendar date = new GregorianCalendar();
day = date.get(Calendar.DAY_OF_MONTH);
month = date.get(Calendar.MONTH)+1;
year = date.get(Calendar.YEAR);
String today = "a_"+year+"_"+month+"_"+day;
System.out.println(today);
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("http://www.yatra.com/");
driver.findElement(By.id("BE_flight_depart_date")).click();
driver.findElement(By.xpath("//a[@id='"+today+"']")).click();
}
}
No comments:
Post a Comment