[英]size of list<webelement> increases after for iteration
I have a problem with my code, the size of my list increases after for iteration : 我的代码有问题,迭代后列表的大小增加了:
@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());
This is the output : Value : 13, 0 1 2 3 4 5 6 7 8 9 10 11 12, Value : 21 这是输出:值:13,0 1 2 3 4 5 6 7 8 9 10 11 12,值:21
can somebody help me please ? 有人可以帮我吗?
try this code : 试试这个代码:
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());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.