【发布时间】:2017-10-29 17:39:52
【问题描述】:
我正在尝试获取随时间变化的 weblement 的价值。值为 -Pending, Approved, Received。
当值更改为Received 时,我必须停止循环。我尝试了下面的代码,但它在一个循环中成功运行,然后在第二个循环中停止,错误为webelement not found with the given xpath。
for(int i=0;i<=50;i++)
{
String exactvalue=driver.findElement(By.xpath("//tr[2]/td")).getText();
if (exactvalue.equals("Received"))
{
break;
}
else
{
driver.navigate().refresh();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException("executing sleep interrupted");
}
}
}
【问题讨论】: