【问题标题】:selenium webdriver - wait until google map all tiles loadedselenium webdriver - 等到谷歌地图加载所有瓷砖
【发布时间】:2017-06-03 05:54:16
【问题描述】:

我是 selenium 的新手,我有点卡住了。
我正在自动化 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
有谁知道我该如何等到所有地图图块成功加载。

谢谢。

【问题讨论】:

    标签: java selenium-webdriver gwt testng-eclipse


    【解决方案1】:

    您可以使用以下方法:

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

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

    【讨论】:

    • By.xpath("(xpath)[last()]"是什么意思
    • (//div[@id='tiles'])[last()] - 其中,[last()] 标识最后一个图块并等待它加载。 (司机,5)正在等待 5 秒,你可以增加你想要的数量
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-23
    • 1970-01-01
    • 2012-06-30
    相关资源
    最近更新 更多