So, what do we do?

Let's face it: working out whether something is ready for you to interact with is actually quite a complex process. What would you do if you were testing the site manually?

That's simple: if you were manually testing the site, you would wait for it to be ready before you start testing. The problem is, what does ready mean?

Well, to me, it means that the page has downloaded, the site has had a chance to render everything that looks like it needs to be rendered, and it appears ready to use. Sometimes, I may start using it before it has downloaded all of the images, but I'll usually wait for the main scaffolding to be in a state that looks ready. Unless I'm looking at the network traffic, I won't know that AJAX requests have resolved, but this is where my experience of what the site should look like comes in.

You may have noticed that I used the phrase "looks ready" a couple of times here. So how do we code "looks ready"? Well, the problem is that you can't; there is a lot of processing that goes on in our brains to come up with "looks ready".

It's like asking a computer to tell you if some cream that has been left in the fridge has gone off. How do you define gone off? Is it a look, or a smell? If there is some mold on the top and we remove it, has it still gone off?

I suspect that, for the last question, some people will have said yes because once it has gone moldy they throw it out, whereas others would quite happily remove the mold and continue using it. So, who is right? What should the computer do?

Obviously, building up a mental model in a computer and asking it to interpret the status of "looks right" is generally not realistic. So, what can we do?

Well, we can programmatically make sure that specific actions have happened before we start trying to do things, or in other words, we can define what "looks right" means in the context of our test. Different tests may have different definitions of "looks right," or they may share a common understanding of "looks right."

We are going to use various types of wait to help us define "looks right."

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.253.152