Skip to content

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 JSON
  • TEST.loadDataFromCsv - to load files from CSV

This helps make your test scripts more reusable and data-driven.

Loading Data from a JSON File

  1. Prepare your data file, e.g. shopping-list.json
json
[
  { "item": "Milk", "quantity": 2 },
  { "item": "Bread", "quantity": 1 },
  { "item": "Eggs", "quantity": 12 }
]
  1. Upload your file to the project.

👉 Navigate to the Advanced Scripting tab of your test project

Advanced Script tab

👉 Click the Add button in the left panel.

Add button

👉 Upload your data file.

Upload File

JSON file

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

  1. Prepare your data file, e.g. shopping-list.csv
csv
item,quantity
Milk,2
Bread,1
Eggs,12
  1. Follow the same steps for uploading data file in the previous example

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

➡️ Full documentation