我有一个包含 Xpath 表达式的 while 循环。我怎样才能让 while 循环在 Xpath 中仅更改 tr[index] 的值时正常工作?下面是一个例子:
//this is what I currently have:
while(webDriver.findElement(By.xpath("//*[@id='sharing_list']/tbody/tr[1]/td[4]")).isDisplayed())
{
webDriver.findElement(By.xpath("//*[@id='sharing_list']/tbody/tr[1]/td[4]/span")).click();
}
//and this is what I would like to have:
int n=1;
while(webDriver.findElement(By.xpath("//*[@id='sharing_list']/tbody/tr[n]/td[4]")).isDisplayed())
{
webDriver.findElement(By.xpath("//*[@id='sharing_list']/tbody/tr[n]/td[4]/span")).click();
n++;
}
有谁知道如何使它工作?我正在使用硒 2.33。
您的帮助将不胜感激。