How to check with Selenium WebDriver if a site is using Ajax? How to check with Selenium WebDriver if a site is using Ajax? selenium selenium

How to check with Selenium WebDriver if a site is using Ajax?


If I were you, I would set up a proxy and route all the WebDriver traffic thru that. In the proxy, for each request I would parse the request headers and look for header

X-Requested-With = XMLHttpRequest

Reference

If you have that, you can (with fair amount of confidence) say, that you had Ajax invoked. There may be some corner cases that you'll miss, but this should get you most of them.

Anyway, you need to consider that Ajax calls may not be done on page load, it may require user interaction to trigger those calls.

You can try to tackle it by using WebDrivers getPageSource() method and apply some method to the output looking for patterns like $.get( and $.post( and $.ajax( and all the other ones that you can come up with.

You may also be interested in this answer about setting up the proxy.