I am using Selenium WebDriver and FirefoxDriver to automate an old website. The website was built using plain JavaScript. It is using XMLHttpRequest
to perform Ajax requests. I want to write a function WaitForAjax()
that should wait for the Ajax request to complete. Currently, I am using Explicit Wait (Thread.Sleep
) to accomplish it. Can anyone help me to accomplish the same with Implicit Wait?
protected void WaitForAjax() {
/*
while (true) {
var ajaxIsComplete = (bool)(_driver as IJavaScriptExecutor).ExecuteScript("return jQuery.active == 0");
if (ajaxIsComplete)
break;
}
*/
//I am using Explicit Waits of 3 second.
Thread.Sleep(TimeSpan.FromSeconds(3));
}