나는 다음과 같은 for 루프를 가지고있다. 그러나 어떤 이유 때문에 loop 내부의 if 구문에 문제가있다. 나는 루프를 제어하기 위해 카운터를 사용하지만 어떤 이유로 카운터가 0에서 시작하지 않고 임의의 숫자로 시작하는 것처럼 보입니다.셀레늄 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
이것은 Selenium과 어떤 관련이 있습니까? – SiKing
그다지 많지는 않지만, 단지 이드가 그것을 다음과 같이 추가한다고 생각했습니다 : P – CoffeeTime