Save results of CSS / XPath custom finds to a variable
Mabl now supports targeting a specific element using CSS or XPath and storing a property of the target element in a variable! For example, you can target an element using CSS or XPath and store its innerText in a variable.

Saving an element's innerText as a variable
Previously, custom find steps could count the number of elements matching a CSS or XPath query and store that number in a variable, but they could not store the result of a CSS or XPath query into a variable. This new functionality allows you to use custom find steps to do the following:
- Select a property of the first or last element that matches a CSS or XPath query
- Preview its current value
- Save it to a variable
This functionality is similar to the process for creating variables from element's property.
If you used a JavaScript snippet as a workaround to save the results of CSS or XPath queries to variables, we recommend migrating those JavaScript steps to use the new custom find step.
Note on creating variables
To extract a property of an element and save it to a variable, the element needs to be accessible to the mabl Trainer at the time the test step is being edited.
If there are no elements on the page matching the given query, a test step creating a variable cannot be saved.
You can learn more about using CSS and XPath to find elements here.