1

I'm new to selenium and I'm kind of stuck.
I'm automating GWT base application and I need to wait till map tiles are fully loaded before moving to next process.
I'm try to find in google but no luck.
I found something like

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");
            }
        }
    );
    }

but, I need to wait untill map tiles loaded not document.readyState
do anyone have idea how can I wait until all map tiles loaded successfully.

Thank you.

Pranav Patel
  • 1,541
  • 14
  • 28

1 Answers1

-2

You can use the below method:

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

Remove the return type and return statements, if you dont want to return the values.

Bala
  • 184
  • 3
  • 19
  • what do you mean by `By.xpath("(xpath)[last()]"` – Pranav Patel Jun 05 '17 at 12:17
  • (//div[@id='tiles'])[last()] - in which, [last()] identifies the last tile and waits for it to get loaded. (driver, 5) is waiting 5 seconds, you can increase as much you wanted – Bala Jun 06 '17 at 05:24