How to capture a dynamic ID from a URL whose request is failing in JMeter? - jmeter

This is in addition to the question already asked:
Please refer the image displayed on clicking the link : https://i.stack.imgur.com/O0lSD.png
Questions:
Is it possible to extract the highlighted values - Blazor ID and Timestamp in JMeter even when the response fails? (Since these values are unique, dynamic and change for each session - it fails on rerunning them)
Is it possible to create/record > amend > run JMeter scripts when we have such dynamic and unique values involved?
I have tried to capture the Blazor ID through Regular Expressions.
But JMeter is not able to capture it from URL (Tried it with all options in JMeter - URL, Body, Headers, Response etc).
Is this because the request is failing? Please have a look at the SS and let me know if anything has to be corrected from my end.
https://i.stack.imgur.com/jK1SF.png
https://i.stack.imgur.com/B2ZNm.png

I guess the Regex Expression need to be change,
for id use id=([^&]*)
and for time use &_=([^&]*)

Related

Is it possible to extract dynamic values from the Response URL through JMeter before it appears in the Response?

Please refer the image displayed on clicking the link : https://i.stack.imgur.com/O0lSD.png
Questions:
Is it possible to extract the highlighted values - Blazor ID and Timestamp in JMeter even when the response fails? (Since these values are unique, dynamic and change for each session - it fails on rerunning them)
Is it possible to create/record > amend > run JMeter scripts when we have such dynamic and unique values involved?
Yes, you can extract them from URL using either Regular Expression Extractor or the Boundary Extractor, just make sure to use the appropriate "Field to check", in your case most probably it will be URL
With regards to the "timestamp" - it can be generated using JMeter's __time() function if it is not present anywhere.

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 how to replay recorded unique id from application

I am very new to Jmeter and trying to use it for doing load testing my application.
In my application, every time we click on a template, application will allocate a unique id which to the template...when I recorded the steps using jmeter, a particular unique id was recorded...but when I tried to play the recorded case...it is looking for the same unique id....how do I tell jmeter to get the new id from the application?
Here are the steps
Login as a user,
click on a particular link,
click on a button which will then popup a window asking to select a template,
After selecting a template, my application will create a unique id for that template
It very much depends on whether that template ID is created on the client (i.e. by JavaScript), or on the server (i.e. you can actually record a template ID returned by the server).
If second is your case, then server returns template ID in the response to template selection, so you can use one of the post-processors - a supporting element invoked after the parent request; it usually extracts data from the response and saves it as a variable(s). In your case you'd extract template ID and save it as variable. Later samplers can use the variable in format ${your_name} instead of the recorded hard-coded string. So in that case your plan could look like this:
Which post-processor to use and how to use it depends on the response you are receiving form the server, so cannot be more specific here.
If the first option is your case (JavaScript on the client generates template ID; and your recording only contains usage of said ID), then you can simulate what JavaScript is doing by generating a similar ID using one of the JMeter script-related features: it could be random function, an inline piece of JavaScript code, a scriptable sampler, such as JSR223 Sampler, or... There are many options really, depending on concrete needs of that generated template ID. Again, a more specific question would help to narrow down your choices.
Classic "correlation" example.
Look for that generated ID in the previous responses (you can do it with the View Results Tree listener)
Once you detect it you need to extract it and convert into a JMeter Variable with a PostProcessor (the most commonly used is Regular Expression Extractor, however depending on the nature of your request you may consider to use others
Once you get the ID extracted and stored in the variable - substitute hard-coded value obtained via recording with the JMeter Variable
Repeat steps 1-3 for any other dynamic parameters or values. Or, consider a faster way of creating a JMeter test via alternative recording solution which performs the above steps automatically so you won't have to worry about detecting and handling dynamic elements. See How to Cut Your JMeter Scripting Time by 80% article for details.
You need to check response of the previous request. Normally ID will be created and can be found in the response of previous request and you can use that ID for next request.
You need to first find in which response the ID is being generated and the format of the ID. You can use firebug to see the response in HTML format and find where the id is.
Once you have the format of the id, create regular expression around it. Test it using regex tester that comes with JMeter. Or you can use rubular.com to check the correctness of your regex.
Once you have correct regex, use regular expression postprocessor on the request which returns the id and then use that variable in actual request that uses unique id.

How to extract value passed in the URL and use it as parameter in Jmeter?

I am using Jmeter for my performance testing and I am stuck at the point where I need to extract the value from the URL and pass it to Jmeter.
Here is the example:
Application requires user to create an order and then submit it on the next page
I am at a point where I can create an order using Jmeter.
In order to create a script to submit an order I have copied the url from the web page as passed it as a GET method '/order/submit/23'. This '23' number changes everytime I create a new order
The issue I am having here is when I run my jmeter script it creates another order with another number which then mismatch with the '/order/submit/23' url I have passed.
Is there any way to extract this number from the HTML code and pass it to Jmeter?
I looked into the HTML code and this number is a part of URL so not sure how I can extract it. Any suggestions please
I am looking for something like /order/submit/${var}
Thanks
If I understood you correctly, you need to extract some value from response. You can do it with two samplers:
XPath Extractor
RegEx extractor
I think xpath extractor more appropriate in your case

Resources