2

I am learning test automation with Robot framework, using this site for practice: http://automationpractice.com/index.php

I know that it is considered a good practice to add waits to make sure the elements are loaded to make tests more robust. It's interesting that though I missed adding any waits in my tests, none of my tests fails.

Googling on this topic only gave me info about benefits of using explicit over implicit waits.

What I really would like to know is:

Should you add waits for all elements that you are going to interact with or only the ones that make the test fail ? What is the approach that gave best results in your experience ?

1

It depends.

If you are using your explicit waits in your framework in such a way that it gets applied behind the scenes of elements without much additional effort, there is no reason not to use it with everything. If done appropriately, performance impact will not be significantly noticeable in most cases.

If your architecture isn't designed this way however, I don't find much advantage in putting it everywhere. Most of your elements will likely be loaded before selenium recognizes the page as being ready to interact with. An additional explicit wait in these cases doesn't do any good. To be clear, Selenium already waits for the Document.readyState to be complete. It's only the case where elements load afterward where explicit waits need to be utilized.

I prefer an architecture that waits without you thinking about it, or only putting them in as you say, when the test fails.

One additional thing that can help, if you setup a way for the PageObject to provide a method to Validate the page is loaded on instantiation, you can provide one or two elements to explicitly wait for, which you know are loaded last, that will eliminate the need to wait in other methods for elements.

-1

I'm not an automation QA but my understanding is that the wait is added in the same class that instantiates the driver ie it is in place and active for all tests rather than being selectively added on a test by test basis.

TLDR: For all elements

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.