API testing using jmeter
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.
jmeter web-api-testing jmeter-5.0
add a comment |
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.
jmeter web-api-testing jmeter-5.0
add a comment |
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.
jmeter web-api-testing jmeter-5.0
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.
jmeter web-api-testing jmeter-5.0
jmeter web-api-testing jmeter-5.0
edited Nov 19 '18 at 1:53
asked Nov 12 '18 at 0:48
A J
5261319
5261319
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
According to JMeter Best Practices you should always be using the latest version of JMeter so considering migrating to JMeter 5.0 (or whatever latest version is available at JMeter Downloads page) on next available opportunity.
If the value you're looking for comes as a HTTP Cookie - it makes a perfect sense to use HTTP Cookie Manager to get the cookies values
add the next line to user.properties file:
CookieManager.save.cookies=true
- restart JMeter to pick the property up
that's it, now you should have all incoming cookies stored as JMeter Variables with
COOKIE_
prefix
Thank you, But I am not getting any values under Jmeter variables. I have set Jmeter variables TRUE under debug sampler. I have updated the question with screenshots.
– A J
Nov 12 '18 at 23:00
To be sure we're at the same page: have you added HTTP Cookie Manager to your Test Plan?
– Dmitri T
Nov 13 '18 at 5:44
Yeah added cookie manager
– A J
Nov 13 '18 at 7:09
Can you show the response in View Results Tree listener withResponse headers
tab open showing the value you want to extract?
– Dmitri T
Nov 13 '18 at 7:20
@ Dmitri T Added.
– A J
Nov 19 '18 at 1:53
add a comment |
The above link uses JSON extractor to correlate the value. As you rightly noticed, the JSON extractor can be used only on the body of the response and not on the headers (cookies mostly appear in the response headers). For this purpose, we will have to revert to our traditional Regular expression extractor.
Select "Field to check" as "Response Headers" and we are good to go. In this case, Regular Expression needs to be utilized for extracting the value and the approach used in the OPs link cannot be leveraged.
For example, if my response headers are as below,
and if I want to capture the NID token which is in line 11 as part of the Set-Cookie parameter, I would use the below Regex.
The cookie value is captured and available for utilization. This is visible in the Debug Sampler.
For additional information on how to do correlation using regular expression extractor, use this link How to do Correlation
Hope this helps!
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254728%2fapi-testing-using-jmeter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
According to JMeter Best Practices you should always be using the latest version of JMeter so considering migrating to JMeter 5.0 (or whatever latest version is available at JMeter Downloads page) on next available opportunity.
If the value you're looking for comes as a HTTP Cookie - it makes a perfect sense to use HTTP Cookie Manager to get the cookies values
add the next line to user.properties file:
CookieManager.save.cookies=true
- restart JMeter to pick the property up
that's it, now you should have all incoming cookies stored as JMeter Variables with
COOKIE_
prefix
Thank you, But I am not getting any values under Jmeter variables. I have set Jmeter variables TRUE under debug sampler. I have updated the question with screenshots.
– A J
Nov 12 '18 at 23:00
To be sure we're at the same page: have you added HTTP Cookie Manager to your Test Plan?
– Dmitri T
Nov 13 '18 at 5:44
Yeah added cookie manager
– A J
Nov 13 '18 at 7:09
Can you show the response in View Results Tree listener withResponse headers
tab open showing the value you want to extract?
– Dmitri T
Nov 13 '18 at 7:20
@ Dmitri T Added.
– A J
Nov 19 '18 at 1:53
add a comment |
According to JMeter Best Practices you should always be using the latest version of JMeter so considering migrating to JMeter 5.0 (or whatever latest version is available at JMeter Downloads page) on next available opportunity.
If the value you're looking for comes as a HTTP Cookie - it makes a perfect sense to use HTTP Cookie Manager to get the cookies values
add the next line to user.properties file:
CookieManager.save.cookies=true
- restart JMeter to pick the property up
that's it, now you should have all incoming cookies stored as JMeter Variables with
COOKIE_
prefix
Thank you, But I am not getting any values under Jmeter variables. I have set Jmeter variables TRUE under debug sampler. I have updated the question with screenshots.
– A J
Nov 12 '18 at 23:00
To be sure we're at the same page: have you added HTTP Cookie Manager to your Test Plan?
– Dmitri T
Nov 13 '18 at 5:44
Yeah added cookie manager
– A J
Nov 13 '18 at 7:09
Can you show the response in View Results Tree listener withResponse headers
tab open showing the value you want to extract?
– Dmitri T
Nov 13 '18 at 7:20
@ Dmitri T Added.
– A J
Nov 19 '18 at 1:53
add a comment |
According to JMeter Best Practices you should always be using the latest version of JMeter so considering migrating to JMeter 5.0 (or whatever latest version is available at JMeter Downloads page) on next available opportunity.
If the value you're looking for comes as a HTTP Cookie - it makes a perfect sense to use HTTP Cookie Manager to get the cookies values
add the next line to user.properties file:
CookieManager.save.cookies=true
- restart JMeter to pick the property up
that's it, now you should have all incoming cookies stored as JMeter Variables with
COOKIE_
prefix
According to JMeter Best Practices you should always be using the latest version of JMeter so considering migrating to JMeter 5.0 (or whatever latest version is available at JMeter Downloads page) on next available opportunity.
If the value you're looking for comes as a HTTP Cookie - it makes a perfect sense to use HTTP Cookie Manager to get the cookies values
add the next line to user.properties file:
CookieManager.save.cookies=true
- restart JMeter to pick the property up
that's it, now you should have all incoming cookies stored as JMeter Variables with
COOKIE_
prefix
answered Nov 12 '18 at 6:47
Dmitri T
69k33458
69k33458
Thank you, But I am not getting any values under Jmeter variables. I have set Jmeter variables TRUE under debug sampler. I have updated the question with screenshots.
– A J
Nov 12 '18 at 23:00
To be sure we're at the same page: have you added HTTP Cookie Manager to your Test Plan?
– Dmitri T
Nov 13 '18 at 5:44
Yeah added cookie manager
– A J
Nov 13 '18 at 7:09
Can you show the response in View Results Tree listener withResponse headers
tab open showing the value you want to extract?
– Dmitri T
Nov 13 '18 at 7:20
@ Dmitri T Added.
– A J
Nov 19 '18 at 1:53
add a comment |
Thank you, But I am not getting any values under Jmeter variables. I have set Jmeter variables TRUE under debug sampler. I have updated the question with screenshots.
– A J
Nov 12 '18 at 23:00
To be sure we're at the same page: have you added HTTP Cookie Manager to your Test Plan?
– Dmitri T
Nov 13 '18 at 5:44
Yeah added cookie manager
– A J
Nov 13 '18 at 7:09
Can you show the response in View Results Tree listener withResponse headers
tab open showing the value you want to extract?
– Dmitri T
Nov 13 '18 at 7:20
@ Dmitri T Added.
– A J
Nov 19 '18 at 1:53
Thank you, But I am not getting any values under Jmeter variables. I have set Jmeter variables TRUE under debug sampler. I have updated the question with screenshots.
– A J
Nov 12 '18 at 23:00
Thank you, But I am not getting any values under Jmeter variables. I have set Jmeter variables TRUE under debug sampler. I have updated the question with screenshots.
– A J
Nov 12 '18 at 23:00
To be sure we're at the same page: have you added HTTP Cookie Manager to your Test Plan?
– Dmitri T
Nov 13 '18 at 5:44
To be sure we're at the same page: have you added HTTP Cookie Manager to your Test Plan?
– Dmitri T
Nov 13 '18 at 5:44
Yeah added cookie manager
– A J
Nov 13 '18 at 7:09
Yeah added cookie manager
– A J
Nov 13 '18 at 7:09
Can you show the response in View Results Tree listener with
Response headers
tab open showing the value you want to extract?– Dmitri T
Nov 13 '18 at 7:20
Can you show the response in View Results Tree listener with
Response headers
tab open showing the value you want to extract?– Dmitri T
Nov 13 '18 at 7:20
@ Dmitri T Added.
– A J
Nov 19 '18 at 1:53
@ Dmitri T Added.
– A J
Nov 19 '18 at 1:53
add a comment |
The above link uses JSON extractor to correlate the value. As you rightly noticed, the JSON extractor can be used only on the body of the response and not on the headers (cookies mostly appear in the response headers). For this purpose, we will have to revert to our traditional Regular expression extractor.
Select "Field to check" as "Response Headers" and we are good to go. In this case, Regular Expression needs to be utilized for extracting the value and the approach used in the OPs link cannot be leveraged.
For example, if my response headers are as below,
and if I want to capture the NID token which is in line 11 as part of the Set-Cookie parameter, I would use the below Regex.
The cookie value is captured and available for utilization. This is visible in the Debug Sampler.
For additional information on how to do correlation using regular expression extractor, use this link How to do Correlation
Hope this helps!
add a comment |
The above link uses JSON extractor to correlate the value. As you rightly noticed, the JSON extractor can be used only on the body of the response and not on the headers (cookies mostly appear in the response headers). For this purpose, we will have to revert to our traditional Regular expression extractor.
Select "Field to check" as "Response Headers" and we are good to go. In this case, Regular Expression needs to be utilized for extracting the value and the approach used in the OPs link cannot be leveraged.
For example, if my response headers are as below,
and if I want to capture the NID token which is in line 11 as part of the Set-Cookie parameter, I would use the below Regex.
The cookie value is captured and available for utilization. This is visible in the Debug Sampler.
For additional information on how to do correlation using regular expression extractor, use this link How to do Correlation
Hope this helps!
add a comment |
The above link uses JSON extractor to correlate the value. As you rightly noticed, the JSON extractor can be used only on the body of the response and not on the headers (cookies mostly appear in the response headers). For this purpose, we will have to revert to our traditional Regular expression extractor.
Select "Field to check" as "Response Headers" and we are good to go. In this case, Regular Expression needs to be utilized for extracting the value and the approach used in the OPs link cannot be leveraged.
For example, if my response headers are as below,
and if I want to capture the NID token which is in line 11 as part of the Set-Cookie parameter, I would use the below Regex.
The cookie value is captured and available for utilization. This is visible in the Debug Sampler.
For additional information on how to do correlation using regular expression extractor, use this link How to do Correlation
Hope this helps!
The above link uses JSON extractor to correlate the value. As you rightly noticed, the JSON extractor can be used only on the body of the response and not on the headers (cookies mostly appear in the response headers). For this purpose, we will have to revert to our traditional Regular expression extractor.
Select "Field to check" as "Response Headers" and we are good to go. In this case, Regular Expression needs to be utilized for extracting the value and the approach used in the OPs link cannot be leveraged.
For example, if my response headers are as below,
and if I want to capture the NID token which is in line 11 as part of the Set-Cookie parameter, I would use the below Regex.
The cookie value is captured and available for utilization. This is visible in the Debug Sampler.
For additional information on how to do correlation using regular expression extractor, use this link How to do Correlation
Hope this helps!
answered Nov 12 '18 at 4:34
M Navneet Krishna
37829
37829
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53254728%2fapi-testing-using-jmeter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown