Writing custom find locators just got a bit easier. Starting with mabl Desktop App version 2.72.0, you can now choose from a list of generated locators and preview how a locator that uses variables matches the page, both of which help you create more resilient custom find steps.
Choose from a list of generated locators
When we introduced Pick an element to generate earlier this month, mabl wrote one locator into the Locator field of your custom find step and left the rest to you. Now you can choose from a list of other locators. If the recommended locator is not quite right, use this list to identify a better long-term choice. For example, if the locator matches text that you know will read differently next month, you could choose an option from the list that doesn't depend on that changing text.
Each row shows the locator, how many elements it matches on the current page, green for exactly one match and amber for any other count, and a short reason it was offered. The recommended row's reason explains why mabl prefers it, and hovering over a truncated reason shows the full text.
Select any row to apply it to the Locator field; the list stays open so you can compare and switch again. If you type your own locator, the list closes, and the next pick replaces it with a fresh set.
Use variables in your locators
Locators in custom find steps could already reference variables with {{@variable}} syntax. Now, they're easier to add in the locator input field:
-
Variable picker: Type
{{@in the Locator field to see the variables available at that step and insert one. - Clearer match preview: The match preview substitutes the values your variables have at that point in the test. If a referenced variable has no value yet at that step, the preview tells you which variable is missing instead of reporting that nothing matched.
- Visual fallback with variables: Select Generate under Visual fallback, and mabl resolves the variables in your locator before writing the description, so a locator that uses a variable no longer blocks generation.
- Variable-aware recommendations: When you pick an element, mabl knows which variables your test has. If the element's text matches one of your variable values, mabl includes a locator that references the variable in the list of other locators, so the step keeps working when the value changes.