Java selenium webdriver-等待google map加载所有分幅
我对selenium还不熟悉,有点被卡住了。Java selenium webdriver-等待google map加载所有分幅,java,selenium-webdriver,gwt,testng-eclipse,Java,Selenium Webdriver,Gwt,Testng Eclipse,我对selenium还不熟悉,有点被卡住了。 我正在自动化GWT基础应用程序,需要等到地图分幅完全加载后再转到下一个进程。 我试图在谷歌上找到,但运气不好。 我找到了类似的东西 public static final void waitTillPageLoad() { WebDriverWait wait = new WebDriverWait(LoginTestScript.fd, 40); wait.until( new Predicate<We
我正在自动化GWT基础应用程序,需要等到地图分幅完全加载后再转到下一个进程。
我试图在谷歌上找到,但运气不好。
我找到了类似的东西
public static final void waitTillPageLoad()
{
WebDriverWait wait = new WebDriverWait(LoginTestScript.fd, 40);
wait.until( new Predicate<WebDriver>() {
public boolean apply(WebDriver driver) {
return ((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete");
}
}
);
}
public静态最终作废waitTillPageLoad()
{
WebDriverWait wait=新的WebDriverWait(LoginTestScript.fd,40);
wait.until(新谓词(){
公共布尔应用(WebDriver驱动程序){
return((JavascriptExecutor)driver.executeScript(“return document.readyState”).equals(“complete”);
}
}
);
}
但是,我需要等待,直到没有加载贴图块document.readyState
有没有人知道我如何才能等到所有地图分幅成功加载
谢谢。您可以使用以下方法:
public boolean checkForPresenceOfElementByXpath(String xpath){
try{
new WebDriverWait(driver, 5)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("(xpath)[last()]")));
return true;
}catch(Exception e){
return false;
}
}
如果不想返回值,请删除返回类型和返回语句。用.xpath((xpath)[last()]”表示的
是什么意思?
(//div[@id='tiles']])[last()]-其中,[last()]标识最后一个tile并等待加载。(驱动程序,5)正在等待5秒,您可以随意增加