You can now save the text contents of a file to a variable. When a test downloads or uploads a text-based file (JSON, CSV, XML, and similar), you can capture what's inside it as a string variable and reuse those contents in later steps. Update to the latest version of the mabl Desktop App to start using it.
With a file-content variable, you can reuse data across steps. Use actual artifacts generated by your application to drive subsequent UI steps, API requests, or JavaScript snippets.
Try it out
In the mabl Trainer, how you create a file-content variable depends on whether your test downloads or uploads the file.
Downloaded files
When you save a download step, you can capture the file's contents at the same time. Fill in Save file contents to variable, next to Save as file variable, and mabl saves the downloaded file's text contents to that string variable without a separate step.
You can also create the file-content variable separately after downloading the file: {x} > Create a variable. Set Set variable using to "File contents" and select the downloaded file from the File variable list.
Uploaded files
Recording a file upload step doesn't make the file's contents available. Add the file to the test as a test data-driven variable first: {x} > Manage variables > Data-driven variables > New file variable.
Then create the file-content variable: {x} > Create a variable. Set Set variable using to "File contents", and select the uploaded file from the File variable list.
Using the variable
Once the file-content variable exists, use it anywhere you would use any other variable:
- Choose {x} > Use a variable and select it.
- Reference the file-content variable in other steps using mabl variable syntax:
{{@varExample}}.
File-content variables work with text-based files only (JSON, CSV, XML, and similar), up to 10 MB. mabl reads the file's contents when the test runs, so the variable always reflects the file produced in that run.