我的代码有问题, 迭代后,列表的大小增加了:
@FindBy(xpath = "//b[@ng-click='column.visible=!column.visible;']")
List<WebElement> columnsNotChecked;
int i = 0 ;
this.waitElementToBeClickable(columns);
columns.click();
System.out.println("Value : " + columnsNotChecked.size());
for (WebElement webElement : columnsNotChecked) {
if (i!=7) {
webElement.click();
}
System.out.println(i);
i++;
}
System.out.println("Value : " + columnsNotChecked.size());
这是输出: 价值:13 0 1个 2 3 4 5 6 7 8 9 10 11 12 值:21
有人可以帮我吗?
答案 0 :(得分:0)
尝试此代码:
List<WebElement> columnsNotChecked = driver.findElements(By.xpath("//b[@ng-click='column.visible=!column.visible;']"));
System.out.println("This is the size of list:"+columnsNotChecked.size());
this.waitElementToBeClickable(columns);
columns.click();
int i =0 ;
for(WebElement webElement :columnsNotChecked){
if(i!=7){
webElement.click();
}
System.out.println(i);
i++;
}
System.out.println("Value : " + columnsNotChecked.size());