chDriver.get("https://www.path2usa.com/travel-companions");
chDriver.findElement(By.xpath("//input[@id='travel_date']")).click();
List<WebElement> datesL = chDriver.findElements(By.className("day"));
int countDays = chDriver.findElements(By.className("day")).size();
for (int i = 0; i < countDays; i )
{
String dateTxt = chDriver.findElements(By.className("day")).get(i).getText();
if (dateTxt.equalsIgnoreCase("28"))
{
chDriver.findElements(By.className("day")).get(i).click();
break;
}
}
I'm studying on Selenium, this code block is taken from Udemy course, but it's not work for me. I don't understand why. If is working properly but not click.
CodePudding user response:
I removed break and it's work properly.
if (dateTxt.equalsIgnoreCase("32"))
{
chDriver.findElements(By.className("day")).get(i).click();
}
}