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.
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.