我们正在使用以下代码片段以安全地传递到下一个测试步骤。
private void waitTextPresent(String toBeExpectedText) throws InterruptedException {
for (int second = 0;; second++) {
if (second >= 60) {
// not found
}
try {
if (driver.findElement(By.cssSelector("BODY")).getText()
.matches(toBeExpectedText))
break;
} catch (Exception e) {
}
Thread.sleep(1000);
}
}
我们正在使用Selenium 2.44.0
(这似乎是稳定版本)。Firefox
版本是 37.0,因为 v38 和 v39 有问题,以前的版本很慢。
然而,即使这个代码片段运行太慢,测试的总时间也太长了。有没有办法以更有效的方式重写这个片段?