What is the difference between "Page Should Contain Element" and "Element Should Be Visible"?
  • 02 May 2023
  • 1 Minute to read
  • Contributors
  • Dark
    Light

What is the difference between "Page Should Contain Element" and "Element Should Be Visible"?

  • Dark
    Light

Article Summary

"Page Should Contain Element" succeeds if the target element is present in the HTML code.
Whether the element is visible or not doesn't affect the result: success or failure.
Note that it succeeds even if the element is not visible on the page, if it is invisible, or if it exists on the negative coordinate.

"Element Should Be Visible" succeeds if the target element is visible and exists.
It will fail if the element is not visible, such as display: none;, visibility: hidden; or opacity: 0;, even if it is present in the HTML code.

Both commands can be set to a wide range of values.

For example, if you want to see a particular form after performing a particular operation, you can select the entire form and use one of the above commands to confirm the purpose of the operation.

However, this command only checks whether the element exists and whether it is visible.
It cannot be used to check if all elements in the area are correct.

If you need to check the correctness of the displayed content, please set a separate command for each element.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.