Robot Framework: Wait Until Element Is Visible vs. Element Should Be Visible, which one is better to use? Robot Framework: Wait Until Element Is Visible vs. Element Should Be Visible, which one is better to use? selenium selenium

Robot Framework: Wait Until Element Is Visible vs. Element Should Be Visible, which one is better to use?


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 use Element Should Be Visible: If your usecase involves visibility of any element, inducing Wait 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).


In a strict performance comparison the execution speed of Wait Until Element Is Visible vs Element Should Be Visible, on element(s) that is already present in the DOM, is virtually the same.
They both do the same thing - find the element in the DOM, and call selenium's is_visible() method. The difference is the Wait Until loops and repeats if any of the two steps fail.

Thus for your (or similar) case, when the presence of one element (the header) should guarantee the other 19 are also already loaded, which one to use shouldn't matter.
If you use Wait Until ... on the header and Element Should Be Visible on the others, you'll be also testing that assumption in your case. Naturally, if all but the 19th elements are loaded together with the header, the case will fail.
If you use Wait Until ... on all elements the chance of passing will be higher - if any of the elements is added and visualized slower than the rest, the kw will wait for it. Obviously this situation will lead to slower runtime - because of the waiting on the condition to be fulfilled.


As for the readability aspect of using one vs the other, I won't comment on that. This is a question of implementation and code structure; you can always make something simple look dreadful, or present a complex solution in a beautiful way :). The same as python allowing you to write code like poetry, or ugly mess (the same goes for some SO answers :D); yours truly is guilty of doing all of this :)