selenium webdriver - 等到谷歌地图加载所有瓷砖

时间:2017-06-03 05:54:17

标签: java selenium-webdriver gwt testng-eclipse

我是硒的新手,我有点卡住了 我正在自动化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");
            }
        }
    );
    }

但是,我需要等待直到加载的地图图块不是document.readyState
有谁知道我怎么能等到所有地图图块成功加载。

谢谢。

1 个答案:

答案 0 :(得分:-2)

您可以使用以下方法:

public boolean checkForPresenceOfElementByXpath(String xpath){
    try{
        new WebDriverWait(driver, 5)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("(xpath)[last()]")));
        return true;
    }catch(Exception e){
        return false;
    }
}

如果您不想返回值,请删除返回类型和return语句。