Sample代码有一段如下,不是很好理解,
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
});
|
我把它重写成了
WebDriverWait WDW = new WebDriverWait(driver, 10);
WDW.until(new theWait());
//(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
// public Boolean apply(WebDriver d) {
// return d.getTitle().toLowerCase().startsWith("cheese!");
// }
//});
// Should see: "cheese! - Google Search"
public static class theWait implements ExpectedCondition<Boolean>{
public Boolean apply(WebDriver d) {
Boolean bool = d.getTitle().toLowerCase().startsWith("cheese!");
if(bool == true)
{
String title = d.getTitle();
System.out.println("Page title is: " + title);
}
return bool;
}
}
|
测试通过,可以做为一个Java函数override的小例子
最新内容请见作者的GitHub页:http://qaseven.github.io/