-1

In a application many fields are there and all the fields are having filters ( text box) . so once user will enter the value in any one of filter immediately UI data (UI table) will start getting refreshed.

I wanted to wait for data to be loaded in UI and then apply the another filter.

Is there any way to wait until data gets loaded without using Thread.sleep

2 Answers2

0

Without further details provided by you, all I can recommend for now is FluentWait. For example:

final WebDriver driver = ...    
new FluentWait<>(driver).withTimeout(30, SECONDS)
    .pollingEvery(1, SECONDS)
    .ignoring(NoSuchElementException.class)
    .until(
        webDvr -> !webDvr.findElements(By.xpath("//tr")).isEmpty()
    );
George Aristy
  • 1,373
  • 15
  • 17
  • Thanks for you reply.... I have scenario like in page we have many filters and by default all data is getting display..... Now i wanted to apply filter one by one and before applying the second(next) filter wanted to wait for get data filter out for first(previous) filter. Also by default " //tr " is present with some data. Please help me out to resolve this as i am new to selenium world. – Tester from Test world Nov 19 '17 at 00:04
0

I could able to perform this using below code -

public  boolean isElementDisplayed(WebElement element) {
    try{                
        WebDriverWait wait = new WebDriverWait(driver, 5);
        wait.until(ExpectedConditions.visibilityOf(element));

        return element.isDisplayed();
        } catch (Exception e) {
            return false;
        }
}


public  void loadingTimer(){
    String xpath = "//span[contains(text(),'Loading...')]";
    WebElement element = driver.findElement(By.xpath(xpath));

    if (isElementDisplayed(element)) {
        WebDriverWait wait = new WebDriverWait(driver , 5);
        wait
           .until(ExpectedConditions
               .not(ExpectedConditions
                   .visibilityOf(element)));
    }
}
mdolata
  • 184
  • 12