1

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!

Slimemold
  • 50
  • 1
  • 7
  • Please see, might help: http://stackoverflow.com/a/5000993/771848 – alecxe Jan 14 '15 at 01:13
  • Hi @alecxe, Thanks for your response! I looked through the thread and I'm still having issues. I could add something like wait.until(notvisible) but I'm really looking to have some sort of ajax watch that will wait until an ajax call is made. – Slimemold Jan 15 '15 at 22:38
  • I could not find a way to have it check and wait for an ajax call. I wound up working around it by having it attempt to enter text into the text field, check to see if the text was empty, and retry until the text was entered correctly. – Slimemold May 21 '15 at 20:56

0 Answers0