I am trying to test a website. After certain fields an ajax script will run. I have tried the following script:
WebDriverWait waiter=new WebDriverWait(Driver, TimeSpan.FromSeconds(10));
waiter.Until(d => ((IJavaScriptExecutor) Driver).ExecuteScript("("return jQuery.active"").ToString().Equals("0"));
However, the ajax scripts are sometimes delayed for a small amount of time. Which causes it to skip this wait period. I want to have selenium wait until there is an ajax call, then continue.
I figured that the next chunk of code would work but I seem to be missing something as it does not work.
waiter.Until(d => !((IJavaScriptExecutor) Driver).ExecuteScript("("return jQuery.active"").ToString().Equals("0"));
Any help is appreciated!