5

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.

6
  • please read stackoverflow.com/help/how-to-ask and provide more info about what you have tried and what didn't work Commented May 15, 2015 at 12:45
  • 2
    Actually, this is an interesting problem. Commented May 15, 2015 at 13:21
  • 1
    What do you mean exactly with "Ajax Based" , If exists some ajax calls or if it is a Simple Page Application ? for example (Angular JS) The problem is there are a lot of approaches by using ajax. it is the main barrier in my opinion. there is not a pattern.. Commented May 15, 2015 at 13:41
  • 2
    It's not really a question, I will consider you read first wiki en.wikipedia.org/wiki/Ajax_(programming) at least. Commented May 15, 2015 at 14:35
  • 1
    For the first one, you should just not worry. Websites are written to gracefully fall back when javascript is not enabled, and thus ajax does not work. For the second one I think you can set up a proxy that you route all your traffic through. Then you analyze all requests that are done. If a click on an element that should yield a page results in a request that does not yield a full html page (<html>....</html>), then it is an ajax request. Commented May 15, 2015 at 17:08

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.