何时在Selenium Webdriver中使用显式等待vs隐式等待?
我在用:
driver.manage().timeouts().implicitlyWait(180, TimeUnit.SECONDS);
但是对于下面的元素,它仍然会不断失败
driver.findElement(By.id("name")).clear();
driver.findElement(By.id("name")).sendKeys("Create_title_01");我添加了等待代码:
for (int second = 0;; second++) {
if (second >= 120) fail("timeout");
try { if (isElementPresent(By.id("name"))) break; } catch (Exception e) {}
Thread.sleep(1000);
}不应该隐含等待,直到找到一个元素?如果我使用显式等待而不是我添加的代码,它会更好Thread.sleep()吗?
侃侃尔雅
芜湖不芜
随时随地看视频慕课网APP
相关分类