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)}")