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.


Why developers are so paranoid about failing Integration tests and Why this is not a problem

When it comes to developers talking about Web Integration tests - you may hear something like "Test should not fail if I move this button" or "If the text on the button changes slightly - test should still pass"

But from my point of view it's ok to fail test because of that. And I would even believe failing test more than passing one.

For a long time I cannot understand the reason of this misunderstanding. And today while reading a book on unit testing - I finally got it.

tl;dr changes in Web Page are more sensitive than changes in API