Appearance
Loading Data from File
UI-licious lets you load dynamic test data from external JSON or CSV files using:
TEST.loadDataFromJson
- to load files from JSONTEST.loadDataFromCsv
- to load files from CSV
This helps make your test scripts more reusable and data-driven.
Loading Data from a JSON File
- Prepare your data file, e.g.
shopping-list.json
json
[
{ "item": "Milk", "quantity": 2 },
{ "item": "Bread", "quantity": 1 },
{ "item": "Eggs", "quantity": 12 }
]
- Upload your file to the project.
👉 Navigate to the Advanced Scripting tab of your test project
👉 Click the Add button in the left panel.
👉 Upload your data file.
- Go back to your test case, and use it in the test script!
javascript
let items = TEST.loadDataFromJson("shopping-list.json")
for (let i = 0; i < items.length; i++) {
I.fill("Item Name", items[i].item)
I.fill("Quantity", items[i].quantity)
I.click("Add to Cart")
}
Loading Data from a CSV File
- Prepare your data file, e.g.
shopping-list.csv
csv
item,quantity
Milk,2
Bread,1
Eggs,12
Follow the same steps for uploading data file in the previous example
Go back to your test case, and use it in the test script!
javascript
let items = TEST.loadDataFromCsv("shopping-list.csv", { header: 'col'})
for (let i = 0; i < items.length; i++) {
I.fill("Item Name", items[i].item)
I.fill("Quantity", items[i].quantity)
I.click("Add to Cart")
}
Learn more
For detailed information on using TEST.loadDataFromJson
and TEST.loadDataFromCsv
, including available options and advanced usage, refer to the full scripting documentation: