When you record a step in a browser test that interacts with an element on the page, such as a click, enter text, or element assertion, mabl tracks over thirty distinct attributes, including text, CSS classes, data-test-id, and other information such as location and size on the page. This information is known as the element history and serves as the foundation of mabl’s intelligent find strategy during subsequent test runs.
If your test starts identifying the wrong element during test runs, you can use results analysis and element history to diagnose the issue.
Note
Element history is tracked separately per environment. For example, if a test runs in two environments, a step tracks element history for both environments separately.
Review changes in element history
If you suspect a test failure is related to a bad element find, you can ask the mabl agent to investigate from the results analysis view. For example:
“Step [N] failed to find the [element description] in this run. Did the element’s attributes (ID, CSS class, text, or other identifiers) change compared to the last passing run? Compare the DOM snapshots and tell me which attributes changed.”
mabl surfaces recent changes in element finds in the supporting evidence section.
Alternatively, if you prefer to refer the logs yourself, you can review the test output logs for the step. On the mabl Activity tab, click on the Element history button to review a table of all the changes in attributes.
To view all changes for a specific attribute, click on the circle icon next to the attribute.
Previous versions of the element, from both auto-heals and small updates, appear in the rows below.
- Small updates: If a strong match for an element was found, but a few attributes changed, mabl makes a small update to the element history as long as (1) the test run ultimately passes and (2) the test run is part of a plan run.
- Auto-heals: If mabl did not find a strong match and attempted an auto-heal, the auto-heal is recorded in the element history as long as (1) the test run ultimately passes and (2) the test run is part of a plan run.
Roll back element history
If the attributes changed, you may roll back to a previous version in the element history. When you roll back the element history, any more recent versions of the element (the rows above the selected version) are deleted. Since element history is tracked separately per environment, rolling back the element history in one environment does not affect the element history in other environments.
Rolling back the element history
Improve find steps
Rolling back the element history does not prevent the same auto-heal from happening again. To ensure mabl targets the correct element in the future, use techniques like Configure Find and visual click to identify the right element.
If the find step was recently recorded and lacks an element history, retrain the find step to use a more targeted find method to keep mabl from selecting the wrong element in future runs. See finding the correct element in browser tests for an overview of options.
Shared element history
In the following cases, an element and its history are shared among multiple steps:
- The same element is used across steps during training. For example, if the test records a click step on an input field and then a step that enters text into the input field, mabl tracks a shared element history for both steps.
- The step is part of a flow, and the flow is used in multiple tests.
- The step, or the entire test, was duplicated. If you duplicate a step, both steps share the same element history. If you duplicate a test, the steps that were duplicated share an element history with their original counterparts.
