Skip to main content

forms Scenario 6 — CSV Data Form Filling Loop

Written by RTILA X Engineering Team

Advanced ~10 min

What You'll Learn

Assert form values and validate outputs

Real-World Use Case

Building automated QA tests for web forms

LIVE DEMO

CSV Form Loop

Three CSV rows inserted, submitted, and reset in a loop.

EXPECTED OUTPUT

CSV Rows

name email
Alice Smith alice@example.com
Bob Jones bob@example.com
Carol White carol@example.com
RTILA X PROJECT JSON

RTILA X Automation Project

csv-data-form-filling.json
{
  "name": "CSV_Data_Form_Filling",
  "settings": {
    "urls": [
      "https://learn.rtila.com/scenarios/forms/6"
    ],
    "variables": [
      {
        "is_list": true,
        "name": "csv_data",
        "required": true,
        "value": "Alice Smith;alice@example.com\nBob Jones;bob@example.com\nCarol White;carol@example.com"
      }
    ]
  },
  "datasets": {
    "csv_rows": {
      "item_selector": "css=#csv-entries tbody tr",
      "properties": [
        {
          "name": "name",
          "type": "text",
          "selector": "css=.csv-entry-name"
        },
        {
          "name": "email",
          "type": "text",
          "selector": "css=.csv-entry-email"
        }
      ]
    }
  },
  "commands": [
    {
      "command": "for_each",
      "params": {
        "source_type": "variable",
        "variable": "csv_data",
        "as": "row",
        "do": [
          {
            "command": "fill",
            "params": {
              "clear_before_fill": true,
              "selector": "css=#csv-name",
              "value": "${row.split(';')[0]}"
            }
          },
          {
            "command": "fill",
            "params": {
              "clear_before_fill": true,
              "selector": "css=#csv-email",
              "value": "${row.split(';')[1]}"
            }
          },
          {
            "command": "click",
            "params": {
              "button": "left",
              "click_count": 1,
              "selector": "css=#csv-submit"
            }
          },
          {
            "command": "wait",
            "params": {
              "timeout": 1000
            }
          },
          {
            "command": "click",
            "params": {
              "button": "left",
              "click_count": 1,
              "selector": "css=#csv-reset"
            }
          }
        ]
      }
    },
    {
      "command": "wait_for_selector",
      "params": {
        "selector": "css=#csv-entries"
      }
    },
    {
      "command": "extract_data",
      "params": {
        "dataset": "csv_rows"
      }
    }
  ]
}

RTILA X Concepts

This pattern uses a for_each loop over a semicolon-delimited list variable. Each row is split, trimmed, inserted into the form, submitted, and then the form is reset for the next row.

Did you complete this scenario?

Ready to run this automation?

Copy the project JSON above, open RTILA X, create a new project, and paste it.

This scenario covers 2 RTILA X commands and is referenced in 2 learning articles.

Continue Learning

Was this helpful?