JMeter: How can I capture the variable value which is dynamic in url? - url

We have a URL https://www.mylink.com/est?myId=4d22b9d0-4ff2-46c3-9343-945304dfea93
The above request also contains post data:
myId=4d22b9d0-4ff2-46c3-9343-945304dfea93
How can I parameterize this as the url and post data both contain same value but its dynamic. Also, how may I store it in a variable to use it somewhere else as well?

In order to be able to use it in URL and request body you need to extract it somewhere somehow, this dynamic ID is probably associated with this or that user account so my expectation is that after logging in you should see this ID somewhere in the response.
The process is known as correlation and there is a plenty of information over the web about handling dynamic requests in JMeter. There are also solutions which provide semi or fully automated correlation of the dynamic parameters like Correlations Recorder Plugin for JMeter or JMeter Proxy Recorder
If you just need to generate an unique GUID-like structure - you can do it using __UUID() function

Related

Jmeter: Dynamic URL encrypted

I'm working on a test plan with Jmeter.
The issue is that I can't retrieve the URL link as he is managed dynamically.
The URL has the following format:
localhost\blablabla?PATHPARAM=qzflh%2FGJHBGDCV%GROPJHVFFFDDFGGCFD%JJYTGVFRTVFGGFF%JUYGBG
I already try to search the value of PATHPARAM in the previous requests to retrieve it using regular expression extractor but I didn't find it.
It seems that this url is generated inside a javascript code but the way to extract it is unknown for me, inside the js code I find the value : var url = actionName + "?" + params ;
Is that any way to catch the content or the var url in Jmeter, else have you any other solution to solve this issue with this dynamic URL.
Many thanks in advance for your help.
I can see 2 possible options:
If you are being redirected to this URL automatically (you might need to play with Redirect Automatically and Follow Redirects boxes in the HTTP Request sampler
If this is the case - you should be able to get it using the following Regular Expression Extractor configuration
If you need to replicate the logic of this param variable calculation - you can attempt to do it using JSR223 PreProcessor which can execute arbitrary JavaScript code

JMeter: Application of Pre-Processor and Post-Processor

I would like to know the Application of Pre-Processor and Post-Processor in JMeter.
As name suggests these components are used to process something (request, response, custom operations) before and after the sampler (request).
Pre processors :
These components are used before the request to perform custom actions.
Ex:
Suppose If I want to add something to request before sending it to server then preprocessor is added. For example if could be fetching some information from DB or Regex operations. Thus after performing those operation we can pass results of these actions to request. Thus we can modify/update request or request parameters before sending request to server.
Post processors :
These components are used after the response of request has arrived to perform custom actions.
Ex:
Suppose If I have asked for something on google and I want to find out something from response for below actions,
To validate response
Extract something and process to pass data to next request
Perform custom actions like DB operations, file operations etc.
Then post processors can be used.
See above snapshot,
Components pointed by arrow will be executed before request is sent to server and components within square will be executed after response has arrived.
I hope this was helpful.
Pre Processors are designed to provide any setup actions required for the test sample like generate some unique test data or amend parent sampler dynamically
Post-Processors are designed to tear down the sampler, or most commonly to extract "interesting" bits from response for later re-use (this is called "correlation")
Pre and Post Processors execution time isn't included into test reports. If you want to change this behavior you need to use Transaction Controller

Jmeter - URL changes when the recorded scripts are run

Please me here as we are newbie to JMeter.
We are performing a Load Test on a module called Reports.
The recorded script (URL) changes during run-time. Following is the example.
Original recorded script (URL):
https://dev.test.com/reportserver/Pages/ReportViewer.aspx?%2FArrowAddOnReport%2FClientsPending&AgencyName=ArrowSeed
URL generated during run-time:
https://dev.test.com/reportserver/Pages/ReportViewer.aspx?%2FArrowAddOnReport%2FClientsPending=&AgencyName=ArrowSeed
If you can see, "=" is added in the URL (highlighted).
Please let us know the reason and resolution to handle the same.
Thanks in advance
I have no idea why it happens, you should talk to DevOPS or whoever is responsible.
Personally I wouldn't use "Path" section to store request parameters, there is a "Parameters" section in the HTTP Request where you can specify required parameters and whether to encode them or not.
If you're completely stuck with an extra = sign I can suggest a workaround.
Add a Beanshell Pre Processor as a child of the problematic HTTP Request
Put following code into Beanshell Pre Processor "Script" area:
String path = sampler.getPath();
sampler.setPath(path.replace("=&","&"));

GET vs. POST (form processing)

I completely understand the differences between the two in terms of form handling, user discretion and privacy of data, but in what situation would anyone rather use GET over POST when sending form results?
Thanks
W3C HTML 4.01 Recommendation on the appropriate usage of GET and POST:
The "get" method should be used when the form is idempotent (i.e., causes no side-effects). Many database searches have no visible side-effects and make ideal applications for the "get" method.
If the service associated with the processing of a form causes side effects (for example, if the form modifies a database or subscription to a service), the "post" method should be used.
Note: The "get" method restricts form data set values to ASCII characters. Only the "post" method (with enctype="multipart/form-data") is specified to cover the entire [ISO10646] character set.
GET places parameters in the URL itself, allowing everyone to see. While POST would be ideal for logins and security-sensitive data, GET is ideal when you want a dynamic page to be bookmarked.
Take a forum for example. The thread which shows all posts within it is loaded dynamically. There doesn't exist a page for every thread available, meaning parameters must be provided which indicate which thread to load. These parameters are passed using GET so that you can bookmark the page and that exact URL with the parameters provided will be used again to load the page.
For instance, to make form data visible in logs.
If i need that user can save a bookmark of next step/page (for whatever reason) i would use GET other than that probably POST.
Both are unsafe and you must escape both.

Can an URL shortener pass parameters?

I use bit.ly to shorten my urls.
My problem - paramters are not passed.
Let me explain I use http://bit.ly/MYiPhoneApps which redirects (let's say) to http://iphone.pp-p.net/default.aspx
Now when I try http://bit.ly/MYiPhoneApps?param=xx this param is not added to the resulting url.
I know I could create an extra "short url" including a paramter - so http://bit.ly/WithParam would result in http://www.mysite.com/somepath/apage.aspx?Par1=yy and so forth.
But what I want is to have a short URL directing to a page - and then I want to add a parameter to this shortened url - which shoul (of course) land at my page.
Is this a shortcome of bit.ly (and others are maybe able to do it) - or does "parameter forwarding" not work with 301 redirections?
Manfred
There's no technical reason why it couldn't be done. The service would simply have to look at what parameters it is being sent, and then rewrite the target URL accordingly.
The problem is that it's not necessarily well defined how to do that.
Suppose you have the url http://example.com/default.aspx?foo=bar, and it has the short url http://foo.com/ABCD. What should happen if you try to access http://foo.com/ABCD?foo=baz? Should it replace the value, so you get foo=baz? Should it append it to make foo=bar&foo=baz? If we include both, which order should they be in?
The system cannot know which parameters are safe to override and which are not, because sometimes, you DO want both of them in the URL, and it may matter what order things are added in.
You could argue "Well, just don't allow this for URLs where parameters are already present", but there's also the issue that it's going to complicate the process a lot more. Without this, you just lookup a key in a database and send a redirect header. Now, you need to also analyze the URL to check for parameters, and append part of the URL you were called by. That requires more system resources per redirect, which may become a big problem if your service is used very frequently - you'll need more server power to handle the same amount of redirects. I don't think that tradeoff is considered to be "worth it".
As mentioned in comments by rinogo and Jurgen
In Clickmeter
Destination URL : www.yoursite.com?myparam1={id1}&myparam2={id2}
Tracking link : www.go.clickmeter.com/38w2?id1=123&id2=abc
After click : www.yoursite.com?myparam1=123&myparam2=abc
In TinyUrl
Destination URL : http://x.com?a=1
Shorten URL : https://tiny url.com/y6gh7ovk
Shorten URL + param : https://tiny url.com/y6gh7ovk?a=2
Resultant URL : http://x.com/?a=1&a=2
Added space to post tinyurl
URL shortening associates a unique key based on a full URL (parameters and all), so it is not possible to pass parameters to a shortening service.
Typically
http://iphone.pp-p.net/default.aspx?param=10
must produce a different key to
http://iphone.pp-p.net/default.aspx?param=22
'Parameter forwarding' is simply not possible in these kinds of redirects, as parameters are not valid parts of a shortened URL is most (if not all) services.

Resources