Overview
Functionize allows you to dynamically use data, such as text or input values, from previous steps in your test case. This is useful for complex verifications or for inputting data that was generated in an earlier part of the test flow. Using the correct syntax is essential to avoid execution warnings or errors.
How It Works
You can reference data from any completed action by using its unique Action ID. This allows you to pull specific attributes like the text displayed or the value entered during that step.
Core Syntax
The standard format for referencing action data is:
{{fze.action('ACTION_ID').ATTRIBUTE}}
For use in custom JavaScript snippets, the syntax is:
fze.action('ACTION_ID').ATTRIBUTE
- ACTION_ID: The unique identifier for the source action, which must be enclosed in single quotes.
- ATTRIBUTE: The type of data to retrieve, most commonly
textorvalue.
Usage Examples
Inputting Data: To enter text from a previous step into a field, use the syntax directly in the input field. For example, to use the text from action '123_ABC':
{{fze.action('123_ABC').text}}Verifying Data: In a Verify action, you can validate against data from a previous step. In the verification settings, set the value to equal the referenced data.
{{fze.action('123_ABC').value}}
Limitations and Common Issues
Incorrect implementation can lead to warnings, such as "Cannot read properties of null (reading 'text')". This typically indicates the system could not find the data using the provided reference.
- Incorrect Quotes: A common mistake is using double quotes instead of single quotes around the Action ID. Always use single quotes.
- Correct:
{{fze.action('123_ABC').text}} - Incorrect:
{{fze.action("123_ABC").text}}
- Correct:
- Referencing an Action Within Itself: You cannot reference an action's data within the same action (e.g., in a post-script). The action's data is only available after the step has been fully executed. Attempting to do so will fail because the data does not exist yet.
- Alternative Solution: If you need to manipulate data from a step, a best practice is to add a Set Variable action immediately after the source step. Store the desired data (e.g.,
fze.action('123_ABC').text) in a variable. You can then use this variable in any subsequent steps, which avoids syntax issues and timing problems.
Related Information
- Using Variables in Tests
- Creating Advanced Verifications