Zvika Nadav Zvika Nadav - 7 months ago 42
jQuery Question

Waiting for a table to load completely using selenium Webdriver with java

Is there a way to wait for a table to load completely using selenium with java?
In my case it looks like the tables loaded using ajax and/or jquery.
So far the only possible solution i could find it so put a simply timeout/pause in a milliseconds.
I'm looking for more advanced solution and not hard-coded one.


Selenium provides WebDriverWait with ExpectedConditions.visibilityOfElementLocated to wait for element visible on the DOM. You should try as below :-

WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement el = wait.until(ExpectedConditions.visibilityOfElementLocated(By...));

Note :- Here you can provide By locator as .id(),.className(), .xpath(), .cssSelector() etc.. of your table element. It will wait for 30 seconds to check visibilty of your table on the DOM.

It will throw TimeoutException exception if element will not be visible within 30 seconds.

For eg :- if you want to check visibility of your table with the id, you just run as wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("your table id")));

You can increase the time also..

Hope it will help you..:)