Reputation: 355
I am having a hard time get the "Regex Expression Extractor" working in Jmeter for the following:
Response Header is something like:
Set-Cookie: Token=dfrtydgsdttetert; Domain=.domain.ca; Path=/;
Expires=Fri, 19 Oct 2018 18:54:18 GMT; Secure
ETag: W/"41c-gdf+/mzdw"
In JMeter Regular Expression Extractor:
Apply to: main sample and sub-samples
Field to check "Response Header"
Name of create Variable: extracted_token
Regular Expression: (?<=Token=)(.*)(?=; Domain) <- the goal is
the get the string "dfrtydgsdttetert"
Template: $1$
Match No: 1
Default Value: ERROR
I tried the above configuration and the extracted_token variable is always "ERROR"
if I change the regex to Token= then I get:
extracted_id_token=null
extracted_id_token_g=0
extracted_id_token_g0=Token=
Please guide me how to fix my configuration so I can retrieve "dfrtydgsdttetert" in the response header.
Upvotes: 1
Views: 294
Reputation: 168002
The "response header" you're trying to extract is basically a HTTP Cookie, JMeter automatically handles cookies via HTTP Cookie Manager so you can just add it to your Test Plan and it will be way more convenient than manually extracting the values from the Set-Cookie header and adding them to Cookie header.
If you need the cookie value for other reason you can get it from the HTTP Cookie Manager itself
Add the next line to user.properties file (lives in "bin" folder of your JMeter installation)
CookieManager.save.cookies=true
Token
cookie value as ${COOKIE_Token}
where required, no need to extract it from the header. More information: HTTP Cookie Manager Advanced Usage - A Guide
Upvotes: 0
Reputation: 34516
To do this extraction the most performing way is to use Boundary Extractor:
If you still want Regular Expression Extractor:
Upvotes: 1