Skip to main content

Overview

Scenarios enable table-driven testing in Supatest. Instead of duplicating test cases for different inputs, define a single test and run it multiple times with different data sets. Each row in the scenarios table represents a unique test scenario with its own variable values. This approach is ideal for:
  • Testing login with multiple user accounts
  • Validating form submissions with various input combinations
  • Checking search functionality with different queries
  • Testing payment flows with different amounts or methods
  • Any test that follows the same steps but uses different data

Enabling Scenarios

  1. Open a test case in the editor
  2. Click the Settings icon in the top-right corner
  3. Toggle on Table-Driven Tests
  4. Click the Scenarios tab to define your data
Enable Table-Driven Tests in settings
When enabled, you’ll see a message: “Scenarios are enabled. Edit test data in the Scenarios tab.”

The Scenarios Tab

The Scenarios tab displays a table where you manage your test data:
Scenarios tab with data table
ColumnDescription
#Row number (auto-generated)
NameDescriptive name for the scenario (e.g., “valid user”, “admin login”)
EnabledToggle to include/exclude the scenario from test runs
Custom columnsYour variable columns (e.g., username, password, expected_result)

Adding Columns

Click + Add Column to create a new variable column:
  1. Enter a column name (this becomes the variable name)
  2. The column is added to the table
  3. Fill in values for each scenario row
Column names become variables accessible via {{ scenarios.column_name }} in your test steps.

Adding Rows

Click + Add Row to create a new scenario:
  1. Enter a descriptive name in the Name column
  2. Ensure the Enabled toggle is on
  3. Fill in values for each variable column

Example Table

#NameEnabledusernamepassword
1correct userOnstandard_usersecret_sauce
2normalOnnormal_usertest123
3admin loginOnadminadmin_pass
4invalid userOninvalidwrong_pass

Using Scenario Variables

Reference scenario variables in your test steps using the scenarios namespace:
{{ scenarios.username }}
{{ scenarios.password }}

Example: Login Test with Scenarios

Step 1: Navigate
URL: {{ env.BASE_URL }}/login
Step 2: Fill username
Selector: [data-test="username"]
Value: {{ scenarios.username }}
Step 3: Fill password
Selector: [data-test="password"]
Value: {{ scenarios.password }}
Step 4: Click login
Selector: [data-test="login-button"]
With this setup, the test runs once for each enabled scenario row, using that row’s variable values.

Running Tests with Scenarios

When you run a test that has scenarios enabled:
  1. The test executes once for each enabled scenario
  2. Each scenario runs independently with its own data
  3. Results show each scenario separately with individual pass/fail status

Understanding Results

After execution, the results display:
Scenario test run results
FieldDescription
Test CaseThe parent test name with an expandable indicator
StatusOverall status (Passed if all scenarios pass)
TotalNumber of scenarios run
Passed/FailedCount of passed and failed scenarios
Expand the test case row to see individual scenario results:
Scenario NameStatusStartedDuration
correct userPassedFeb 4, 2026, 01:13:08 PM14s
normalPassedFeb 4, 2026, 01:13:23 PM8s
Each scenario shows:
  • Scenario Name: The name you defined in the table
  • Status: Pass or Fail for that specific scenario
  • Started: When the scenario began execution
  • Duration: How long the scenario took

Import and Export CSV

Manage your scenario data using CSV files:

Export CSV

  1. Click Export CSV in the Scenarios tab
  2. Save the file to your computer
  3. Use for backup, sharing, or editing in spreadsheet software

Import CSV

  1. Click Import CSV in the Scenarios tab
  2. Select a CSV file with matching column structure
  3. Scenarios are populated from the CSV data
CSV Format Requirements:
  • First row must be column headers
  • Must include name and enabled columns
  • Additional columns become variable columns
  • enabled values: true/false or 1/0
Example CSV:
name,enabled,username,password
correct user,true,standard_user,secret_sauce
normal,true,normal_user,test123
admin login,true,admin,admin_pass

Best Practices

Naming Scenarios

  • Use descriptive names that explain what the scenario tests
  • Good: “valid credentials”, “expired password”, “locked account”
  • Avoid: “test1”, “scenario2”, “row3”

Organizing Variables

  • Keep column names short but meaningful
  • Use consistent naming: user_email not userEmail in one and user-email in another
  • Group related variables logically in the table

Managing Large Tables

  • Disable scenarios temporarily instead of deleting them
  • Use CSV export to version control your test data
  • Split very large tables into multiple test cases if needed

Debugging Scenarios

  • Run individual scenarios by disabling others
  • Check variable names match exactly between table and expressions
  • Verify all required columns have values for each row

Combining with Other Features

Scenarios + Environments

Use both for comprehensive coverage:
URL: {{ env.BASE_URL }}/login
Username: {{ scenarios.username }}
This allows testing different users across different environments.

Scenarios + Loops

Scenarios iterate through rows; loops iterate within each scenario execution. Use loops when you need to repeat steps multiple times for a single scenario.

Scenarios + Conditionals

Add conditional logic that responds to scenario data:
Condition: {{ scenarios.user_type == 'admin' }}
  -> Verify admin dashboard visible
Otherwise:
  -> Verify user dashboard visible

Troubleshooting

Variable Not Found

  • Verify the column name in the Scenarios tab matches your expression
  • Check for typos and case sensitivity
  • Ensure the column exists and has a value

Scenario Not Running

  • Check that the scenario’s Enabled toggle is on
  • Verify Table-Driven Tests is enabled in settings
  • Ensure there’s at least one enabled scenario

Wrong Values Used

  • Confirm you’re using scenarios. prefix, not vars. or env.
  • Check the scenario row that ran matches expected values
  • Review CSV import if data was imported

All Scenarios Fail

  • Test with a single scenario first to isolate issues
  • Check that step selectors work with the provided data
  • Verify environment variables are set correctly