How to iterate through these “available” dynamic cells
How to iterate through these “available” dynamic cells
M
Posted on 20/12/2016
I am trying to get selenium iterate through these available dynamic cells so as to confirm that the dynamic link "x seat left" (x=number of seats) is present on any of the cells.
public static void selectDate(String date) throws Exception{
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); Date dateToBeSelected = df.parse(date); Date currentDate = new Date(); String monthYearDisplayed = driver.findElement(By.xpath("//*[@id='ui-datepicker-div']/div[1]/div/div")).getText();
System.out.println("month year displayed " + monthYearDisplayed); String month = new SimpleDateFormat("MMMM").format(dateToBeSelected); String year = new SimpleDateFormat("yyyy").format(dateToBeSelected); String day = new SimpleDateFormat("dd").format(dateToBeSelected); String monthYearToBeSelected=month+ " "+year; System.out.println(monthYearToBeSelected);
while(true){ if (monthYearToBeSelected.equals(monthYearDisplayed)) { //select date driver.findElement(By.xpath("//a[text()='"+day+"']")).click(); System.out.println("Found and Selected"); break;
}else{//if you are not in the right month & year, you have to then navigate to the right month & year