Element assertion FAQs

Commonly asked questions about element assertions

Can I assert that an element is not on the page?

If you want to assert that an element does not exist on the page, depending on the circumstances, you can take one of the following approaches:

  1. Work backwards: Create an "is not present" assertion while the element is still on the page. The assertion runs after being created and fails. Move the step to the position in your test where you expect it to be absent. See an example of this strategy in the following animation.
1280

Working backwards to create an "is not present" assertion

  1. Use a custom find assertion: If the element doesn't appear during testing, but you can identify it with CSS or XPath, you can record a custom find assertion and select the "is not present" assertion type.

Can I assert against an element that only appears on hover?

If the element only appears briefly or disappears when you try to record an assertion step, consider trying one of the following workarounds:

  1. If the tooltip is clickable, record a click step on the tooltip and convert that step into an assertion using assert on element
  2. If you are familiar with CSS or XPath selectors, you can try creating a custom find assertion.

Can I assert against an SVG element?

Recorded assertions against SVG elements are not supported, though you can assert against SVG elements with a custom find step. Depending on what your end goal is, you might consider one of the following workarounds:

  • Asserting on the element that contains the SVG element, also known as the parent element.
  • If you want to assert on an SVG element's attributes, you can try creating this two-step workaround:
    1. Create a variable from JavaScript. Use or modify this snippet to extract properties from the SVG element.
    2. Make an assertion against the variable value.

If you need a different type of support for SVG assertions, please let us know in the mabl Product Portal.

Can I assert against CSS properties?

CSS style properties are not included in the element assertion menu. One workaround is to use a JavaScript snippet. Click here for more information.

📘

Under consideration

This feature is currently listed as "Under Consideration" in the mabl Product Portal. If you would like to see support for assertions against CSS properties without using JavaScript, you can add your feedback here.

Can I assert that a page or image has fully loaded?

There is no direct way to assert whether a page or image has fully loaded. One workaround is to assert on an element, element property, or element attribute that consistently indicates that the page or image is fully loaded. Ultimately, it depends on how your page works

Can I assert that the date is the current day?

If an application shows the current date in a specific format, you can create an assertion with some help from JavaScript. See our guide on working with dates in mabl for more information.