Jmeter Tips

Jmeter Useful tricks to get and pass session id to another request.

JMETER USEFUL TRICKS


  1. 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

    General Regex to capture whole token "(.+?)"

  1. 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}

  1. 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.

  1. 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.
User defined variables
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
Using variable in HTTP Request

Comments

  1. 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.
    Regards:

    Software testing training
    Software training

    ReplyDelete

Post a Comment

Popular Posts