public ArrayList vTimeDifference(){
ArrayList<Integer> hourList = new ArrayList<>();//This list is for storing new hour list
List<WebElement> hours2 = webElements(hours);
for (WebElement timeList : hours2) {
String hour3 = timeList.getText().replaceAll("[^0-9]", "");
String hour4= hour3.replaceAll("[^\\d.]", "");
int hour5=Integer.parseInt(hour4);
hourList.add(hour5);
System.out.println(hourList);
}
return hourList;
}
//看起来有点复杂from darksky
TimeDifference()的公共无效验证{
ArrayList<Integer> timing = new ArrayList<>();
List<WebElement> hours1=getElements(locator);
for (int i=0; i < hours1.size(); i++) {
String text=hours1.get(i).getText();
String hours11=text.replaceAll("[^0-9.]", "");
if(hours11.equals("")){continue;}
int abc =Integer.parseInt(hours11);
timing.add(abc);
}
System.out.println(timing.get(3));
}
这是我找到的答案,它可以正常工作