Here I Want to know webpage has AJAX calls or not. Because if webpage is AJAX based then I will wait for few seconds to get the web page contents, or else if webpage is not AJAX based then I will not wait .
I followed the below code but I didn't get any result.
WebDriver driver = new PhantomJSDriver(caps);
driver.get("http://www.airgas.com/category/Safety-Products-Clothing-WorkClothing-Acc/_/N-0Z84v");
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("$(document).ready(function() {
$(document).ajaxStart(function(event, request, settings) {
alert("Web Page have Ajax Calls");
});
});
);
If I use the jQuery code which I used in javascriptexecutor
in developers console I am getting alert message stating that webpage has AJAX calls or not.
So is my approach is correct? If not what is the correct solution for my problem.