Is it possible to test the absence of a specific element?
  • 10 Jun 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Is it possible to test the absence of a specific element?

  • Dark
    Light

There are several ways to check that a certain element is not found.

If the target is a string

You can use the standard assertion command.
Please click here for further information.

If the target does not have a string

If you want to check that an element does not exist on a page

You can use a [JS Step].

var selector = "<TODO: REPLACE SELECTOR>"; //Please replace
var element  = document.querySelector(selector);
if (element) {
    throw new Error('Error: There is an element that shouldn’t exist (' + selector + ').');
}

If you want to check that an element is not displayed on a page (the element exists in the invisible state)

Contents coming soon…


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.