How to check with Selenium WebDriver if the site uses Ajax?

I do research and development on several unknown third-party sites to get page content using selenium.

How do I know if a website is based on Ajax or not Ajax. I don’t know any data inside an unknown website to check using the name or tag name, so how should I check it based on Ajax or not.

+5
source share
1 answer

If I were you, I would set up a proxy and lay all the WebDriver traffic. In the proxy for each request, I parsed the request headers and looked for the header

 X-Requested-With = XMLHttpRequest 

Link

If you have this, you can (with sufficient confidence) say that you called Ajax . There may be some corner cases that you miss, but this should attract you to the most.

In any case, you need to keep in mind that Ajax calls cannot be made when the page loads, it may require user interaction to start these calls.

You can try to solve this problem using the WebDrivers getPageSource() method and apply some method to the output looking for patterns like $.get( and $.post( and $.ajax( and all the others you can think of.

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

+1
source

All Articles