Approaches to handling AJAX in Web Automation (Selenium)

Unfortunately pretty much places in web applications automation are based on "Magic". What do I mean by saying magic?

Example of Magic:
  1. Test is failing (or some operation is failing) and you don't know why
  2. You are trying something - and is works
  3. BUT you can't explain why the thing you done helps to fix the situation, and is it reliable or not

So, talking about JS/AJAX handling - it's mostly based on Magic for now. Nobody knows how to handle it properly, neither I do.

In this article I'll try to explain how to get rid of Magic in JS/AJAX handling as much as possible. Just theory, without code examples.


Random Data in Test Automation

Using random data can be pretty tricky. As always there are two types of people - who uses random a lot, and who don't.

Let's compare these two ways.

Random No Random
  • Every run you get a new set of data to use
  • Coverage is increasing with each test run
  • You don't need to think about duplicates in data, assuming random is working well
  • Every run is on same (or identical) set of data
  • Pesticide Paradox in place
  • You need to handle duplicates - delete data from previous runs, or in some other way
From the table above using Random seems to be the best choice, but there are some pitfalls.