JMETER 5.2.1 : Why parameters tab is disabled in some of the requests and how to handle requsts in this case - jmeter

I am new to JMETER , I am trying to record my web application and correlate JSESSION IDs and other details.
JSESSION ID , i want to capture from previous request and send as parameter in next request.
But in the next request parameters tab is disabled. I see in some posts that body should be empty to have parameters tab.
In the attached screenshot , if I make body empty , how do I pass the parameters.can anyone please help me . I am not able to proceed further

If you're testing a REST API and want to parameterize the contents of your payload you can just inline the relevant JMeter Function and/or Variable directly into the request body like:
{"sessionId":"","ipAddress":"","autoLogin":"N","numberLoginAttempts":0,"cookie":"JSESSIONID=${JSESION}"}
If you will still be experiencing problems use Debug Sampler and View Results Tree listener combination in order to check that:
Your JSESION variable exists
It has expected value

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:

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 RegUx User Parameters not adding parameter

New to JMeter, and I'm probably missing some simple thing but I can't find it anywhere.
I'm trying to log into a web application so I send a GET request to the home page to retrieve the csrf token and then I use the regular expression extractor to retrieve it:
I then try to place the extracted token into the POST request:
But the extracted token doesn't show up in the request sent via the View Results Tree. Only the UserId and Password are passed which I manually defined:
My regular expression is finding a match as you can see here:
but even if it wasn't finding a match, it should still pass "NotFound" correct?
Any help is greatly appreciated!
Edit: Added a Debug Sampler and it is correctly showing the variable Token with it's correct value. So Token just isn't being added to the request via the RegEx User Parameter Pre Processor.
It's difficult to see what you're doing without seeing the LoginPage step, but you need to make sure you are adding the csrf token you've extracted in the right place.
Typically it could be as a query param, part of a post body or an http header.
As you can see the token has been extracted from your initial response in the Debug sampler, there must be something wrong in how or where the token is being applied to the LoginPage request. (As you say the RegEx User Parameter Pre Processor isn't adding it)
I've never used the PreProcessor and the Jmeter documentation explanation is a bit vague on what it does, but you can add the variables into your request without it using the variable saved for the capture groups - for input name this will be ${Token_g1} and for value it will be ${Token_g2} - which you will be able to see from the Debug Sampler. You'll need to add a Header or Cookie Manager to the Login Page element if this is where the token is.
By setting the template in the Extractor to $1$$2$ you create a variable with the name and value concatenated together. I'm not sure why you would need this, and I would guess that the name doesn't change - in which case you can just use capture group 2, or if you want to use the Variable name Token then update your template to be $2$

Automate sending a request and saving the response

There is a URL which I want to hit and save the response. The URL id needs to be incremented each time and save the response. For example -
First Get Request - http://google.com/getdata/?Id=1
First Response - one
Second Request - http://google.com/getdata/?Id=2
Second Response - two
and so on...
I want to hit the request with increment the id each time and save the response
I have tried using fiddler but unable to figure how to increment the id and save the response.
P.S. - I have to make around 6,00,000 hits
Since the 'Postman' tag is mentioned, I can help you regarding how to implement this in Postman.
Postman has a nice feature of using 'variables'.
You can use environment variables or globals.
Read more about these on their docs:
https://www.getpostman.com/docs/v6/postman/environments_and_globals/variables
You can use a global variable such as 'counter' and set it to 1 / whatever starting point you want.
Then you can modify your request like so :
http://google.com/getdata/?Id={{iteration}}
Now, in the Tests script of the request you can write the following script
let i = parseInt(pm.globals.get('iteration')) + 1;
pm.globals.set('iteration', i);
Also, to access the response you can use the following command in Test script:
console.log(pm.response); // Use pm.response as per your needs
Save the request in a collection.
Now load the Postman's Runner and select the collection.
Now you can put an iteration count of 6,00,000 and hit run!
Remember, heavy iterations will cause performance degradation.
In JMeter you need to click , Ctrl+0 and Ctrl+1 to create , Thread Group and HTTP Request
In Thread Group put the number of hits you need in Number of Threads (users)
In HTTP Request Put in Server Name or IP www.google.com and in Path /getdata/?Id=${__threadNum}
__threadNum will create increasing number from thread 1 to number of hits.
For small number of hits or debugging you can add View Results Tree to view request/response by clicking Ctrl+9 in Test Plan/Thread Group level.
To save the response use Post Processor, especially by adding Regular Expression Extractor below HTTP Request by clicking Ctrl+2.
Allows the user to extract values from a server response using a Perl-type regular expression. As a post-processor, this element will execute after each Sample request in its scope, applying the regular expression, extracting the requested values, generate the template string, and store the result into the given variable name.
Import to notice that for load testing you need to work with non GUI mode, which means call jmeter using command line as jmeter -n -t myTest.jmx
you will use Command-line mode (called Non-GUI mode) to run it for the Load Test.
Don't run load test using GUI mode !
For saving all responses to a one file see save response data or if you want to save file per thread/user you can add Save Responses to a file
Fiddler:
Open script editor (Control + r ) then add the following code inside OnBeforeResponse
static function OnBeforeResponse(oSession: Session) {
if(oSession.oRequest["X-SAVE-ME"] != "")
{
oSession.SaveResponseBody("C:\\tempfiddler\\" + oSession.SuggestedFilename);
}
}
Go to the "Composer" tab and include the header X-SAVE-ME with any value, in the URL, replace your ID with # (just like this: http://google.com/getdata/?Id=#) fiddler will now ask for the starting and ending value of ID before executing;
Please find the snapshot below for your scenario.
Scenario_Testplan
First, go to user properties and put "sample_variables = ID, Response_File_Name" or whatever the name you choose for the variables. Restart jmeter.
Create the below plan:-
CSV data set config to have incremental values and response file name
HTTP request will use ${ID}
Save response to a file will use ${Response_File_Name}
Hope this will help.
I would do this by command line, using a while loop with a curl to the URL, storing the body result on the standard output to a file. It would look something like this:
for i in {1..600000}; do curl "http://google.com/getdata/?id=$i" > body-result-id-$i; done
I couldn't test the line above because I don't have any access to a console right now, but I think it should work.
In Burp you can do this using the Intruder tool. First, capture a sample request in Burp. If you're unsure how to do this, please consult the getting started documentation.
Then right-click the request and selected "Send to Intruder".
In the Positions tab within Intruder, first click "Clear" then select the section you want to vary, and click "Add"
In the Payloads tab select the Payload type as "Numbers" and configure the range.
Click "Start attack"
For more information, consult the documentation.
One Another solution is that you can use Counter in jmeter. That you can find from below path
Thread Group > configElement > Counter.
Configure the Counter as per your need.
Give the Reference Name i for counter.
Use the variable in your request
For more information.

How to capture and use the dynamic value generated in the same service in Jmeter?

I have recorded a script, where a dynamic value (user_token) is generated. The same value has to be used in the same service. The previous services before this service are using GET methods, so I was not able to use regular expression before the service.
Please find the screen shot of the script.
Would you please confirm on the below.
If your script is recorded . then the current sampler what you attached, what it tells to us is , The user_token is populated automatically while recording . i.e., initially login.html was recorded with username and password you provided , then next sampler signin.html recorded with additional user_token
between login.html and signin.html samplers, you got your user_token ,i.e., login.html response contains user_token ,so would you please add regex post processor to login.html http sampler and try accessing the "user_token" value to a variable and use that variable in Signin.html
I have used the regular expression in login.html as suggested by Suman. Yes it is capturing the value and passing it to the next samplers.
Here im receiving an another problem after execution.
Im receiving the below error:
javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name
Please find the screen shot.
error

Resources