How to fetch parent url of the current failing url in jmeter?
I am trying to fetch the parent url of the current failing request (for eg consider a travel website ,parent url will be search creteria and current url is selecting flights page).How can we do it .I tried it with putting a if controller after failing url and a beanshell so that it fetches the parent url of all the failings flights request. But what is happening is ,if the current flight request is falining it wont go to the next if controller at all. Execution stops. Can someone guide me with the better way?
jmeter jmeter-4.0
add a comment |
I am trying to fetch the parent url of the current failing request (for eg consider a travel website ,parent url will be search creteria and current url is selecting flights page).How can we do it .I tried it with putting a if controller after failing url and a beanshell so that it fetches the parent url of all the failings flights request. But what is happening is ,if the current flight request is falining it wont go to the next if controller at all. Execution stops. Can someone guide me with the better way?
jmeter jmeter-4.0
add a comment |
I am trying to fetch the parent url of the current failing request (for eg consider a travel website ,parent url will be search creteria and current url is selecting flights page).How can we do it .I tried it with putting a if controller after failing url and a beanshell so that it fetches the parent url of all the failings flights request. But what is happening is ,if the current flight request is falining it wont go to the next if controller at all. Execution stops. Can someone guide me with the better way?
jmeter jmeter-4.0
I am trying to fetch the parent url of the current failing request (for eg consider a travel website ,parent url will be search creteria and current url is selecting flights page).How can we do it .I tried it with putting a if controller after failing url and a beanshell so that it fetches the parent url of all the failings flights request. But what is happening is ,if the current flight request is falining it wont go to the next if controller at all. Execution stops. Can someone guide me with the better way?
jmeter jmeter-4.0
jmeter jmeter-4.0
asked Nov 14 '18 at 7:02
unknownabcd
122
122
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
- First of all forget about Beanshell, you should be using JSR223 Test Elements and Groovy language for scripting starting at least from JMeter version 3.1 (for earlier versions it was also recommended, however Groovy engine wasn't included in JMeter distribution)
- Add JSR223 PostProcessor as a child of the 2nd request
Put the following code into "Script" area:
if (!prev.isSuccessful()) {
log.info('Previous sampler name: ' + ctx.getPreviousSampler().getName())
log.info('Previous sampler URL: ' + ctx.getPreviousSampler().getUrl().toString())
}
That's it, you should see the name of the previous sampler and its URL in the Log Viewer panel and in jmeter.log file

You can save the URL into a JMeter Variable like:
vars.put('url', ctx.getPreviousSampler().getUrl().toString())
once done you will be able to access the value as
${url}where required.
References:
prevstands for current SampleResult
ctxis a shorthand for JMeterContext
varsis a shorthand for JMeterVariables
See JavaDoc for the above classes for description of used functions and Apache Groovy - Why and How You Should Use It article for more information on Groovy scripting in JMeter.
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%2f53294718%2fhow-to-fetch-parent-url-of-the-current-failing-url-in-jmeter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
- First of all forget about Beanshell, you should be using JSR223 Test Elements and Groovy language for scripting starting at least from JMeter version 3.1 (for earlier versions it was also recommended, however Groovy engine wasn't included in JMeter distribution)
- Add JSR223 PostProcessor as a child of the 2nd request
Put the following code into "Script" area:
if (!prev.isSuccessful()) {
log.info('Previous sampler name: ' + ctx.getPreviousSampler().getName())
log.info('Previous sampler URL: ' + ctx.getPreviousSampler().getUrl().toString())
}
That's it, you should see the name of the previous sampler and its URL in the Log Viewer panel and in jmeter.log file

You can save the URL into a JMeter Variable like:
vars.put('url', ctx.getPreviousSampler().getUrl().toString())
once done you will be able to access the value as
${url}where required.
References:
prevstands for current SampleResult
ctxis a shorthand for JMeterContext
varsis a shorthand for JMeterVariables
See JavaDoc for the above classes for description of used functions and Apache Groovy - Why and How You Should Use It article for more information on Groovy scripting in JMeter.
add a comment |
- First of all forget about Beanshell, you should be using JSR223 Test Elements and Groovy language for scripting starting at least from JMeter version 3.1 (for earlier versions it was also recommended, however Groovy engine wasn't included in JMeter distribution)
- Add JSR223 PostProcessor as a child of the 2nd request
Put the following code into "Script" area:
if (!prev.isSuccessful()) {
log.info('Previous sampler name: ' + ctx.getPreviousSampler().getName())
log.info('Previous sampler URL: ' + ctx.getPreviousSampler().getUrl().toString())
}
That's it, you should see the name of the previous sampler and its URL in the Log Viewer panel and in jmeter.log file

You can save the URL into a JMeter Variable like:
vars.put('url', ctx.getPreviousSampler().getUrl().toString())
once done you will be able to access the value as
${url}where required.
References:
prevstands for current SampleResult
ctxis a shorthand for JMeterContext
varsis a shorthand for JMeterVariables
See JavaDoc for the above classes for description of used functions and Apache Groovy - Why and How You Should Use It article for more information on Groovy scripting in JMeter.
add a comment |
- First of all forget about Beanshell, you should be using JSR223 Test Elements and Groovy language for scripting starting at least from JMeter version 3.1 (for earlier versions it was also recommended, however Groovy engine wasn't included in JMeter distribution)
- Add JSR223 PostProcessor as a child of the 2nd request
Put the following code into "Script" area:
if (!prev.isSuccessful()) {
log.info('Previous sampler name: ' + ctx.getPreviousSampler().getName())
log.info('Previous sampler URL: ' + ctx.getPreviousSampler().getUrl().toString())
}
That's it, you should see the name of the previous sampler and its URL in the Log Viewer panel and in jmeter.log file

You can save the URL into a JMeter Variable like:
vars.put('url', ctx.getPreviousSampler().getUrl().toString())
once done you will be able to access the value as
${url}where required.
References:
prevstands for current SampleResult
ctxis a shorthand for JMeterContext
varsis a shorthand for JMeterVariables
See JavaDoc for the above classes for description of used functions and Apache Groovy - Why and How You Should Use It article for more information on Groovy scripting in JMeter.
- First of all forget about Beanshell, you should be using JSR223 Test Elements and Groovy language for scripting starting at least from JMeter version 3.1 (for earlier versions it was also recommended, however Groovy engine wasn't included in JMeter distribution)
- Add JSR223 PostProcessor as a child of the 2nd request
Put the following code into "Script" area:
if (!prev.isSuccessful()) {
log.info('Previous sampler name: ' + ctx.getPreviousSampler().getName())
log.info('Previous sampler URL: ' + ctx.getPreviousSampler().getUrl().toString())
}
That's it, you should see the name of the previous sampler and its URL in the Log Viewer panel and in jmeter.log file

You can save the URL into a JMeter Variable like:
vars.put('url', ctx.getPreviousSampler().getUrl().toString())
once done you will be able to access the value as
${url}where required.
References:
prevstands for current SampleResult
ctxis a shorthand for JMeterContext
varsis a shorthand for JMeterVariables
See JavaDoc for the above classes for description of used functions and Apache Groovy - Why and How You Should Use It article for more information on Groovy scripting in JMeter.
answered Nov 14 '18 at 7:53
Dmitri T
69.1k33458
69.1k33458
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%2f53294718%2fhow-to-fetch-parent-url-of-the-current-failing-url-in-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