1

I am trying to do some API testing in Jmeter. I was trying to follow this https://octoperf.com/blog/2018/04/23/jmeter-rest-api-testing/ . But I need to get token from cookie.

Can anyone suggest me a solution? Using Jmeter version 5.0

Sorry, if this question was asked previously. But, I could't find a solution.

2 Answers 2

2

Normally APIs don't use cookies so my expectation is that you need to extract HTTP Header value instead

  1. Take a look at Response Data -> Response Headers mode of the View Results Tree listener and locate the value you need to extract.

    enter image description here

  2. Add Regular Expression Extractor as a child of the request and use the relevant regular expression in order to extract the interesting value. For example:

    • In order to extract gws from Server: gws header the regular expression would be Server: (.*)
    • In order to extract 1P_JAR cookie value the regular expression would be 1P_JAR=(.+?);

    • Don't forget to change Regular Expression Extractor's "Field to check" to Response Headers

    enter image description here

More information:

0

Add the next line to user.properties file (located in the "bin" folder of your JMeter installation)

CookieManager.save.cookies=true Restart JMeter to pick the property up Add HTTP Cookie Manager to your Test Plan Now you should be able to refer cookie values as:

${COOKIE_session} and ${COOKIE__xsrf} CHk More info https://stackoverflow.com/questions/45520455/how-can-i-extraxt-session-id-and-xsrf-token-through-cookies-in-jmeter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.