Xpath 式を含む while ループがあります。Xpath 内で tr[index] の値のみを変更して、while ループを適切に動作させるにはどうすればよいですか? 以下に例を示します。
//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++;
}
それを機能させる方法を知っている人はいますか?Selenium 2.33 を使用しています。
あなたの助けは非常に高く評価されます。