I am doing Research and Development on few unknown third party websites to get page content using selenium.
How should I get to know whether website is Ajax based or non-Ajax based. I don't know any data inside of unknown website to check though using id or tag name, so how should I check it Ajax based or not.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With