I have this test plan where I recorded my login via HTTP(S) Test Script Recorder in JMeter.
It works just fine for the recorded user. But when I tried to change the user info it won't work.
Here's my skeleton:
Under my thread group,
First, I have "Critical SEction COntroller" to run my requests in order because I hvae a lot of requests.
Then, I have my "CSV Data Set Config" where I gave my csv file that contains my user info. (Username and login)
Then, I have "HTTP REquest" which I'm using it to load my login page. (GET Request)
Then, I have my "Recording Controller" to store recorded script elements. Under this I have my "HTTP REquest" where I send my credential (POST Request) and alongside with that other requests that won't affect this question.
On the "HTTP Header Manager" of the request that I mention on step 4, I don't have any info such as "Authorization" which contains the token under 'Headers Stored in the HEader MAnger' column. However on the web side, as a response bearer token is generated. So output of my searchings, I learned that I have to put "REgular Expression Extractor" under the request I mention on step 4, to extract the generated token and pass it onto next requests.
Name of the variable for the extraction is "BearerToken", and my regex to extract that is
BearerToken=([\S]+), and as a default value I wrote "TokenNotFound"For the further request's "header manager"s I do have the info such as "Authorization" which contains the token under 'Headers Stored in the HEader MAnger' column. Therefore I simply replace the token with
Bearer ${BearerToken}expression.And lastly, I put "DEbug Sampler" to check if I get everything correctly, even though I get my user credentials correctly, I always get "TokenNotFound"
I can't extract the token, therefore I cannot login for multiple users.
Unfortunately we cannot help you without seeing your response data and Regular Expression Extractor configuration.
Make sure that response contains the pattern you're looking for
Make sure that your regular expression works using "RegExp Tester" mode of View Results Tree listener
Check that Regular Expression Extractor "Apply to" field and its scope are correct.
More information: JMeter Regular Expression Extractor: How to Extract Tokens and Session IDs to Variables