Jmeter Tips
Jmeter Useful tricks to get and pass session id to another request.
JMETER USEFUL TRICKS
- Create RegExHTTP Request
Request to extract token from request through RegEx
Regular Expression Extractor
Reference Name: authToken
Regular Expression: "authorizationToken":"(.+?)"
Template: $1$
Match No.: 1
Reference Name: authToken
Regular Expression: "authorizationToken":"(.+?)"
Template: $1$
Match No.: 1
General Regex to capture whole token "(.+?)"
- Create JSON Regex
Add “Destionation Variable Name” : tokenidjosn
Add JSONOPath Expression: $.token
If response is like
{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1NTc5NGJiMmE0ODAzYjNmZmU1ZmYxMWEiLCJpYXQiOjE0MzY3NjkzOTI3NDMsImV4cCI6MTQzNjc4NzM5Mjc0M30.YGNJzS50rXTy8TM__7-RKDh7vL2xhNFfC03LPKJu3Bg"}
Use response of above request to next request by adding e.g., {tokenidjson}
- If you want to pass header information then
Add HTTP Header Manager and add/pass content into it. E.g., token variable etc.
If want to pass parameter then only add into request.
- Hardcoding is not good if you have hundreds of samplers in test-plan so I decline such way. I’ll go to User Defined Variables element and fill its fields as specified in Figure 4.
Figure 4
I add variable PATH that has value “/changes.html”. In “Description” field I specify for what purpose I’m going to use this variable. After that I switch to Http Request and replace “/changes.html” with expression ${PATH}, where PATH is name of variable that was defined previously. Look at Figure 5
Excellent way of writing and expressing your thoughts and ideas to the readers, very much impressed in your article. Keep doing more, waiting to read your next blog.
ReplyDeleteRegards:
Software testing training
Software training