Jmeter string functions through user defined variable - jmeter

I am putting some jmeter string functions in a user defined variable like below:
testdata = ${__char(165)}${__char(165)}My${__unescape(\r\n)}Deepak${__unescape(\r\n)}Play${__changeCase(Deepak\, change case,UPPER,)}
But when I am passing this value in request Body Data as ${testdata}, jmeter string functions are not resolving and I see below request in view result tree listener Request Body tab:
${__char(165)}${__char(165)}My${__unescape(\r\n)}Deepak${__unescape(\r\n)}Kumar${__changeCase(Deepak\, change case,UPPER,)}
However, when I pass above same data directly in request Body Data instead of ${testdata}, it works perfectly fine with all string functions resolving in view result tree listener request body data.
I am using Jmeter 5.3 on Windows 10 with OpenJDK 14.0.1. One of my colleagues is not facing the same issue.

I cannot reproduce your issue using latest stable JMeter 5.3:
In the vast majority of cases if JMeter doesn't do what it is supposed to be doing you can figure out the reason from jmeter.log file so it worth checking it for any suspicious entries

Related

Dynamic Refid is appended to the URL but i can't find refid in the response

When i perform the action on UI a dynamic refid is appended to the URL using query string parameter. I can't find that refid in the response but its part of the request. In the code i only found the variable.
Here is the URL on UI.
https://XXXXXX.XXXXXXXXXXXX.com/Recruiter/#!/candidate/new/157072048
I captured the Get request for the same action using the developer tool on Chrome and it looks like this.
Request URL: https://XXXXXX.XXXXXXXXXXXX.com/Pages/candidate/new.aspx?refid=157072048&mode=quick
This Get request has 2 query string parameter.
refid: 157072048
mode: quick
Now i need to captured that refid and pass it the step 2 to be able to create that record. I need help to figure this out.
I found comment in the html that may be help full.
// referenceid - only used with the "Web" app, gets mapped to "&refid=123" in the query string, and ends up as Page.ReferenceID in WebForms.
If this is not a part of a response data then it might be the case it's generated on the client by JavaScript code. You need to figure out how the value is being generated and replicate the same code using JSR223 Test Elements and Groovy language.
Another possibility is that the value comes from an Ajax request which JMeter doesn't execute because it cannot execute client-side JavaScript. In this case you need to simulate the same request and extract the value from there.
And last but not the least, the number you're looking for may reside in one of the sub-samples which may appear as the result of Redirection and you're trying to find it in main sampler response:

Using JMETER GUI JDBC Request with Callable Statement – how do I getResultSet/MetaData?

I’ve got a call to my database working as a SQL select statement. But I am working to call a stored procedure using JMeter for further testing. I’m strictly working off of the JMX files and do not have JMETER integrated into our main Java project at this time.
I’ve setup the JMETER GUI with the JDBC Connection Configuration and the JDBC Request. I’ve made a successful call to my database with my callable statement with my string INPUT and get the string OUTPUT parameter string.
The OUTPUT parameter string only contains information about the call (user,system, success, etc…), but none of the values/data from the table -- which are found in the ResultSet/MetaData. But I cannot figure out how to get the ResultSet or the Metadata using the JDBC Request in JMETER.
In Java, I know I use the statement and just call statement.getResultSet() and perform a loop while resultSet.next() exists. How do I do this in JMETER?
I've tried adding an additional out parameter but then my statement rejects the call, because there is only one in-parameter. I've tried a variety of JMeter Assertions - but because the main call is only returning the out parameter, I cannot grab additional data.
Query: call XXXXX.readUser(?)
Parameter Values: ${inputJSONString}
Parameter Types: INOUT VARCHAR
Variable Names: ouputJSONString
Result Variable Name: ouputJSONString
View Results Tree: Response code: 200, Response message: OK, Output variables by position: Contains the whole JSON out parameter string with user, system, and success. Returns the table column headers but no values.
I do not have errors - the call is being made successfully. I just cannot figure out how to access the Result Set from JMETER.
Don't use the same reference name for the Variable Names and the Result Variable Name as the latter one will be overwritten.
So
Change ouputJSONString to i.e. ouputJSONStringObject
Add JSR223 PostProcessor as the child of the request
You will be able to access the JMeter's representation of the ResultSet as vars.getObject('ouputJSONStringObject') (basically ArrayList of HashMaps
See Debugging JDBC Sampler Results in JMeter article for more details.
Unfortunately you cannot access the normal ResultSet as it is not exposed anywhere and being converted via private function

field name is getting changed in response data

Field name is getting changed after executing the script.
A. After executing the script,the field name is not getting displayed in response data but the parameters are displayed with slight changes.
In sampler below details are getting displayed.
Name : aura.token
Parameters : HCQAHBgEMTAwMBQCGAcxMDAwMjA5GAcxMDAwMjA5ABQCGfMQscHV8XF654tDbfY0XD3yRxaSwbvRh1oAGfMgzIG_YaBrAZdWB-IAMP_0iAQiYMHheBA3BA0SoXzWh4kA
but after execution of a script below details are getting displayed in response data.
*/{"event":{"descriptor":"markup://aura:invalidSession","attributes":{"values":{"newToken":"HCQAHBgEMTAwMBQCGAcxMDAwMjA5GAcxMDAwMjA5ABQCGfMQkaKR6n5r5QqE7gz5Qk1l1Rb67KOtiFoAGfMgtKaMHHWJZiXEOt8pU6zs1edK_Q4dQo5VL2ea8y2qi3gA"}}},"exceptionEvent":true}/*ERROR*/
It's name is "newToken". So why do you think this should not be changed?
Most probably you need to perform correlation of this field, to wit you will not be able just to record and replay the script as this "token" is being generated dynamically and has new value each time you access the application.
The main idea of the correlation is
Identifying dynamic elements. The easiest way is to record your test scenario one more time using HTTP(S) Test Script Recorder and compare the recorded scripts. All parameters which are different needs to be handled properly.
Wherever you detect a dynamic parameter look into previous sampler response data (body, headers, Cookies, URL) - the value should be there
Apply a relevant Post-Processor to the previous sampler in order to extract the dynamic value and store it into a JMeter Variable
Replace recorded value with the JMeter Variable from the previous step
You should be good to go now.

JMeter - how to use dynamic variable in a HTTP request path

I am wondering how I can use a dynamic variable in the Path field of a HTTP request . I am able to use User Defined Variables, but they are static, I need to use a variable that extracts some unpredictable value from the response of a previous HTTP request. I.e. the URL in the below scenario resolves literally to /this/and/that.jspx?param1=${testvar} , so you can see ${testvar} is not being substituted. How do I get ${testvar}, a variable created during regex extraction in a previous HTTP Request, to be substituted?
FYI I am using JMeter 2.11 and upgrading may not be an option (corporate policies... )
JMeter Variables resolution/substitution works normally no matter of JMeter version, I can think of 2 possible reasons:
You're looking into wrong place. You should be inspecting Request tab of the View Results Tree listener in order to see the actual URL
Your ${testvar} variable is not defined, i.e. Regular Expression Extractor fails to extract the required value. You can double check it using Debug Sampler:

How to parameterized request if getting recorded script like this.? See details

How to parameterize request if I am getting something similar to the following for login POST request in body data tab.
"{\"msg\":\"method\",\"method\":\"login\",\"params\":[{\"user\":{\"username\":\"testuser\"},\"password\":{\"digest\":\"5811c74a581ffdb892ab9eddfb9cf2d21772a98332a59de6aa26989e01f84057\",\"algorithm\":\"sha-256\"}}],\"id\":\"7\"}"]
It's generally easy to correlate when we are getting in Parameters TAB, but in cases how we can proceed? For all further requests - it's the similar case.
I tried to switch to Parameters TAB, but it says that it can not be converted to that format.
So How we can proceed?
The same way, just substitute hard-coded (recorded) values with the relevant JMeter Variables directly in the request body like:
"{\"msg\":\"method\",\"method\":\"login\",\"params\":[{\"user\":{\"username\":\"${username}\"},\"password\":{\"digest\":\"${password}\",\"algorithm\":\"sha-256\"}}],\"id\":\"${id}\"}"]
The most commonly used for parameterization test element is CSV Data Set Config, however other options exist.

Resources