Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wait for "loading" icon to disappear from the page

we are doing automation for web application and most of the scenario getting loading icon will appear at center of the page .. we need to wait for dis appear to loading icon

<div id="loading" style="display: none; visibility: hidden;">
<div></div>
<div></div> 

Example : we are having search functionality their in most of scenario we are getting this loading icon.

selenium webdriver we are using: id we are getting for loading to complete is id= "loading"..please any give the solutions for the above issues am facing.

we have different functionality like click & sendkeys

like image 530
Sunil wali Avatar asked Mar 18 '23 18:03

Sunil wali


1 Answers

Explicit Wait should help:

public static String waitForElementNotVisible(int timeOutInSeconds, WebDriver driver, String elementXPath) {
    if ((driver == null) || (elementXPath == null) || elementXPath.isEmpty()) {

        return "Wrong usage of WaitforElementNotVisible()";
    }
    try {
        (new WebDriverWait(driver, timeOutInSeconds)).until(ExpectedConditions.invisibilityOfElementLocated(By
                .xpath(elementXPath)));
        return null;
    } catch (TimeoutException e) {
        return "Build your own errormessage...";
    }
}
like image 99
Matthias Avatar answered Apr 06 '23 16:04

Matthias