Search code examples
jqueryseleniumdatatableswait

Wait for jQuery DataTable loaded with Selenium


I would like to know if there is a way with XPath or CssSelectors, if there is a consistent way to wait until a jQuery DataTable has finished loading for use with Selenium.


Solution

  • See https://datatables.net/reference/event/processing.

    This event is fired when DataTables is doing some kind of processing - be it, sorting, filtering or any other kind of data processing

      public static void WaitUntilDataTableHasFinishedLoading(this IWebDriver driver, IWebElement processingTable)
        {
            processingTable.WaitForAttribute("style", "display: none;");
        }
    

    Usage:

           IWebElement x = SeleniumInfo.Driver.FindElement(By.Id("tableName_processing"));
    SeleniumInfo.Driver.WaitUntilDataTableHasFinishedLoading(x);