Additional methods for element assertions

In some cases, asserting against the right element is a challenge. You may be asserting against an element that is very similar, or identical, to other elements on the page. Or the properties and attributes of an element have dynamically generated values. Or the element only briefly appears when you hover over a different element.

If you are unable to assert against the correct element using a recorded assertion step, here are some additional methods you can try.

Add Configure Find

If the assertion is targeting the wrong element, try adding Configure Find to specify which element attributes are the most important.

📘

Auto-healing assertions

When you use Configure Find for an assertion, you must choose between auto-heal (default setting) or fail this step. Fail this step disables auto-heal.

For more information on how these settings affect "is present" and "is not present" assertions, click here.

Assert on element

If recording a regular assertion for an element proves to be difficult, another option is to convert an existing step that finds the element, such as a click step, into an assertion:

  1. Click on More actions (...) for the click step that you wish to convert.
  2. Select Assert on element from the dropdown.
294294
  1. Set the criteria for your assertion.
  2. Click OK. The existing click step will have been converted into an assertion step.

Custom find assertion

You can use custom CSS queries or XPath IDs to identify the element you wish to assert against. To create a custom find assertion, take the following steps:

  1. Click on the plus symbol to add a new step.
  2. Select Find elements
  3. In the custom find view, you can use CSS or XPath to identify the element in the browser window.
  4. For the action, select Make assertion.
  5. When you click Next, you can set the criteria for your assertion in the element assertion menu.

👍

Try Configure Find first

Before using CSS or XPath, we recommend trying to identify the correct element with Configure Find.

A native click assertion that uses Configure Find is easier to maintain, and a custom find assertion should only be used in cases where Configure Find does not include the attributes needed to correctly identify the element.

For an overview on identifying elements in mabl, read our documentation on finding the correct element.


Did this page help you?