Skip to main content
Version: 2.29

Assigning and Accessing Variables

Assigning variables

Variables can also be directly created and assigned for use within a Feature File. A new variable can be created and assigned a value using the following step:

I assign "ABC" to variable "my_stoloc"

Accessing variables

Once a value is stored in a variable, the variable can be used in any subsequent step within a given Scenario in place of a step argument by referencing the variable with the $ qualifier.

I enter $my_stoloc
Quoted variables

Cycle treats any text between quotes as a literal string. This means that a $VAR inside of quotes is not treated as a variable. For example, the step:

I enter "$lodnum"

would result in $lodnum being typed on the screen.

Echoing variable values

One way to see the value of a variable is using:

I echo $my_stoloc