I know that both of them can be used to validate if an element appears on the page but I was wondering about the performance impact and readability implications of each. So my question is, suppose you have 20 elements to check in the page,
- Is it better to use Wait Until Element Is Visible for all 20 elements?
OR
- Use Wait Until Element Is Visible for one element (for example, a header text) to let my automation script know that the page has loaded AND then use Element Should Be Visible for the rest (e.g. form fields)?
Yes, factually both of them can be used to validate if an element appears on the page but ofcoarse you can design your tests for a much better performance.
Ideally, the Waits should be implemented strictly as per your Usecase and Test Steps.
Using
Wait Until Element Is Visible
: If your usecase involves visibility of all the 20 elements, albeit Wait Until Element Is Visible is the best fit.Using
Wait Until Element Is Visible
for header text AND then useElement Should Be Visible
: If your usecase involves visibility of any element, inducingWait Until Element Is Visible for header text
would be a complete overhead. As you have no validation with the header text, this step isn't necessary. Rather you should directly induce Wait for the visibility of the desired element(s).