I encountered in Jmeter that I can not solved. I want to create a test that send request and get the response. the response is url encode. So first I need to put the response in a variable and than to url decode it. 1. I create regex and put the response in variable name "full_response", it saved as expected as you can see in results. 2. I created a groovy sampler step and just want to pass the "full_response" and print it, to know that it is passed OK. and it is not print all the response just the 3 letters. (I think because the response is URL ENCODE). Can someone please advise how to pass this variable to groovy script? and than print it? the purpose is to url decode the results and put assertion on it!! How I can put the results in "reponse_before_decode" variable in groovy sampler, and than to url decode it. in the debug sampler I not see the response_before_decode variable that I created in the groovy sampler Is it because the response is with special chars? and I can not pass it as whole>? (see the response in full response variable that is with regex) regards
def reponse_before_decode = args[0] as String;
def reponse_before_decode_2 = args[0];
System.out.println ("re" + '$full_response');
System.out.println ("full" + reponse_before_decode_2);
System.out.println ("full" + reponse_before_decode);
${full_response}
, use vars.get('full_response')
instead as it might conflict with GStringTemplatesYou don't need Regular Expression Extractor interim step, you can access previous Sampler result from the JSR223 Sampler like:
def reponse_before_decode = ctx.getPreviousResult().getResponseDataAsString()
where ctx
stands for JMeterContext class instance
x-www-form-urlencoded
strings. See Apache JMeter Functions - An Introduction to get familiarized with JMeter Functions concept.