---
title: "Set variable in a web test"
sidebarTitle: "Set variable"
description: "Define a value once and reuse it across a web test: a generated username, a constant, or a value built from other variables."
lastUpdated: "2026-09-23"
---

> **For AI agents:** the complete documentation index is at [llms.txt](/llms.txt). Append `.md` to any page URL for its markdown version.

Define a value once and reuse it across the test: a username generated at the start of the run, a constant you don't want to repeat, a value built from other variables.

## Parameters

| Parameter | Required | Description |
| ----------- | ---------- | ------------- |
| Variable name | Yes | Name of the variable to create or overwrite. |
| Value | Yes | The value to store. Supports text, other variables, and functions like random text. |

## Results and metrics

- **Variable**: available to every later step of the test. Insert it anywhere a field supports variables.
- **Timing and status**: recorded in the step result like any other step.

See [Variables](/tests/variables) for variable types and the functions you can use in values.

## What's next?

<Columns cols={2}>
  <Card title="Extract value" icon="arrow-up-from-bracket" href="/tests/actions/web/extractvalue">

    Capture a value from the page instead of defining it

</Card>
  <Card title="Variables" icon="brackets-curly" href="/tests/variables">

    Test variables, global variables, and functions

</Card>
</Columns>
