---
title: "Variables in Transaction Tests"
slug: "variables-in-transaction-tests"
updated: 2023-01-06T15:48:57Z
published: 2023-01-06T15:48:57Z
canonical: "docs.catchpoint.com/variables-in-transaction-tests"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.catchpoint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Variables in Transaction Tests

Selenium variables can be used to store and extract constants within Transaction tests. These constants can be used to pass variables from one step to another within a single test. The correct syntax is below:
`storeVariable("${extract('<resp-header|resp-content(default)>','<regexp with extraction>',{'optional-chained-sub-macros'})}","<VariableName>")`   `extractVariable("<VariableName>") `

#### **Below are two instances where *variables* are commonly used:**

***Passing a cookie value from one step to another.*** You can extract the cookie from the header, store it as a variable, then retrieve it later on in the test. Please see the code for this below.
`open(http://www.google.com)` 
`StoreVariable("${Extract(resp-header, regexp:set-cookie:(.*))}", "cookie")`   `open(http://www.google.com)` 
`setheader("Cookie", "${extractVariable(cookie)}") `

***Extracting value from the response content, storing it as a variable, then set it as a custom header later on in the test**. *Please see the code for this below.
`open(http://www.google.com)` 
`StoreVariable("${Extract('resp-content', 'regexp:<title>(.*)</title>')}","title")`` ` 
`open(http://www.google.com)`  
`setheader("Title:", "${extractVariable(title)}") `
