У меня есть следующий цикл for, но по какой-то причине им не удается попасть в операторы if внутри цикла. Я использую счетчик для управления контуром, но по какой-то причине счетчик никогда не начинается с нуля и, кажется, начинается с случайных чисел.Selenium Управление контуром Webdriver, бесконечный цикл Java
Есть ли у кого-нибудь идеи относительно того, что не так с моим кодом.
public static void chk_DateAreInRange() throws Exception{
try
{
Date startDate = new Date();
Date endDate = new Date();
int abc = 0;
elementString = driver.findElement(By.id("ctl00_Content_gvList"));
final List<WebElement> dates = elementString.findElements(By.xpath(".//td[1]"));
do
{
for (WebElement date : dates)
{
System.out.println("inside dates for" +abc);
if(abc == 0)
{
System.out.println("inside if x=0");
String[] parsedString = date.getText().toString().split("\\-");// splits the webelement into a string from the - icon
Date ddd = formatter.parse(parsedString[0]);//gets the date we need from string - 12 Nov 2014
String startdateString = formatter.format(ddd);
startDate = formatter.parse(startdateString); // convert the string back into a date
}
if(abc == 99)
{
System.out.println("inside if x=99");
String[] parsedString = date.getText().toString().split("\\-");// splits the webelement into a string from the - icon
Date ddd = formatter.parse(parsedString[0]);//gets the date we need from string - 12 Nov 2014
String startdateString = formatter.format(ddd);
endDate = formatter.parse(startdateString); // convert the string back into a date
}
abc++;
}
}while(abc != 99);
if(getFromDateFull().before(startDate) || getToDateFull().after(endDate)){System.out.println("Date is not in range");}
}catch (Exception e){
Log.error("TOP dropdown is not found on the PLP View Schedule Page");
throw(e);
}
}
Консольный выход.
inside dates for349625
inside dates for349626
inside dates for349627
inside dates for349628
inside dates for349629
inside dates for349630
inside dates for349631
inside dates for349632
inside dates for349633
inside dates for349634
inside dates for349635
inside dates for349636
inside dates for349637
inside dates for349638
Что это связано с селеном? – SiKing
не так много, просто подумал, что добавить его в: P – CoffeeTime