2017-06-03 52 views
1

我是新来的硒,我有点卡住了。
我自动化GWT基础应用程序,我需要等到地图切片完全加载后才能转到下一个进程。
我试图找到在谷歌,但没有运气。
我发现像selenium webdriver - 等到谷歌地图加载所有瓷砖

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

您可以使用以下方法:

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语句,如果你不想返回值。

+0

你是什么意思Byxxpath(“(xpath)[last()]” –

+0

(// div [@ id ='tiles'])[last()] - 其中,[last )]标识最后一个磁贴并等待它加载(驱动程序,5)正在等待5秒钟,你可以增加你想要的数量 – Bala

相关问题