I am getting the Billdesk URL in the response of booking API, I have to navigate to the URL and make payment on browser. Can we do it using Jmeter? - jmeter

I am new to Jmeter. I am getting the below-mentioned code in the response of the Booking API. I have to click on the 'requestUrl' field. It will redirect me to the browser and opens the billdesk page where I have to make payment. After successfull payment, my booking will be done. Each time we are getting the different URL. Can we do this using Jmeter?
"data": {
"requestUrl": "https://uat.billdesk.com/xyz",
"redirectUrl": "http:xyz",
"orderNumber": "5904"
}

Add JSON Extractor as a child of the request which returns the above JSON
Configure it as follows:
Names of created variables: anything meaningful, i.e. requestUrl
JSON Path Expressions: a JsonPath query matching the request URL, i.e. $.data.requestUrl
Other fields can be left intact:
Add HTTP Request sampler after the first request and put ${requestUrl} into "Path" field:
That's it, in the runtime the ${requestUrl} JMeter Variable will be substituted by the value from the previous request JSON response:
More information: API Testing With JMeter and the JSON Extractor

Related

Set the whole request url in jmeter

I have a request, which gives upload url as response body.
{
"uploadUrl": "https://test.com:9000/sample_uploadurl"
}
I'm able to extract the uploadUrl using JSON extractor.
I want to use above upload url to in next http request. How to set the new request here ?
adding directly doent work, because JMeter prepends http/https before request, in this case we already have https.
It got failed because it has https://[https://test.com:9000/sample_uploadurl]
Leave HTTP Request fields empty except Path, put there the variable and it will be executed
As a special case, if the path starts with "http://" or "https://" then this is used as the full URL.
example
The options are in:
Put the whole ${UPLOAD_URL} to "Path" field of the HTTP Request sampler like:
however this approach might be flaky and cause the malfunction of certain configuration elements like HTTP Cookie Manager. So it's better to go for option 2.
Split the ${UPLOAD_URL} into individual components like protocol, host, port and path.
Add JSR223 PostProcessor after the JSON Extractor
Put the following Groovy code into "Script" area:
URL url = new URL(vars.get('UPLOAD_URL'))
vars.put('protocol', url.getProtocol())
vars.put('host', url.getHost())
vars.put('port', url.getPort() as String)
vars.put('path', url.getPath())
The above code will generate the following JMeter Variables
So you should be able to use the generated variables in the next HTTP Request sampler:

JMeter: Is it possible to add HTTP Request sampler during run?

I have an HTTP request that returns a JSON object that contains multiple urls (mostly image resources).
I do not know the number of the urls that will be in the response JSON and that number may vary during time.
I need to create an HTTP request for each of the urls that i received.
Is it possible to create HTTP Request samplers while running the JMeter flow?
Is there a different solution one can advise me to do in order to send HTTP requests to the list of the urls?
Thanks
Add JSON Extractor as a child of the main request and come up with a JSON Path expression to extract links to images and whatever else URLs you would like to hit
Add ForEach Controller and configure it to read the JMeter Variable reference name from step 1 and set output variable to anything meaningful
Add HTTP Request sampler as a child of the ForEach Controller and configure it to use the output variable
That's it, JMeter will trigger a HTTP Request sampler for each URL present in the original JSON
Given you have the following JSON:
{
"urls": [
{
"url": "http://example.com"
},
{
"url": "http://jmeter.apache.org"
},
{
"url": "http://jmeter-plugins.org"
}
]
}
You can extract the URLs into JMeter Variables using the following JSON Extractor setup:
it will give you the following JMeter Variables:
url_1=http://example.com
url_2=http://jmeter.apache.org
url_3=http://jmeter-plugins.org
url_matchNr=3
now if you add ForEach Controller and configure it like:
you will be able to refer the URLs as ${current_url} in the HTTP Request sampler which is the child of the ForEach Controller

How to pass post method response value through another post method request value

In Jmeter, how to use AUTH “access_token” for passing through header for another POST request ? Below are the step that i have done but it's not working ... How to use "access_token" value, that will use another post request dinamically ? Attached issues is here...
enter image description here
You need to add jp#gc-JSON Path Extractor in HTTP request, the particular HTTP request which is generating access token in its response data .
If response is like - {"access_token":"f5b06970-f00f-4b44-89c8-305738e19cba"}
In JSON path extractor add
Variable name - access_token (variable in which access_token will be stored)
2.JSON Expression - $.access_token (this will varry according to json response)
3.Default Value - NOT_FOUND
Now the next step is to use this variable named "access_token ". You can use it in your HTTP request for which you need to pass access token under HTTP header manager as access_token = ${access_token }
below link will help you a lot:
https://www.blazemeter.com/blog/advanced-usage-json-path-extractor-jmeter

Jmeter - Want redirected URL to be displayed in response data as its giving response code 302 in response header

I have generated a jmeter script.
But I'm not getting anything in response data (View tree listner).
I'm getting Response code: 302 and Response message: Moved Temporarily in response header (View tree listner) also giving the URL to which it is redirected in Location field in response header.
I want this redirected URL to be displayed in response tab.
the url i wnat in response data]1
You can fetch the URL using Regular Expression Extractor.
Add Regular Expression Extractor as a child of the HTTP Request sampler
Configure it as follows:
Field to check: Response Headers
Reference Name: JMeter Variable name of your choice, i.e. location
Regular Expression: Location: (.*)
Template: $1$
You will be able to access the extracted URL as ${location} or `${__V(location)}} where required.
See Using RegEx (Regular Expression Extractor) With JMeter article for more information on correlating dynamic values in JMeter test.

Jmeter If controller with http code

I want to use if controller in my jmeter load testing. The test is:
do a post and get back an access token.
use that access token to get the next link.
My issue:
I have the access token and have used the post-assertion->regular expression extractor and got the access token from he http response. But now I don't know how to use the if control and ask it do next test only if the http response code is 200. And second question is can i still pass my regular expression value of access token into the if loop's http header manager?
attaching the screen shot of my jmeter.
Try to use Response Assertion to handle state of Request_Access_Token request (success/failure) depending on Response Code returned and then use IfController along with pre-defined JMeterThread.last_sample_ok jmeter's variable - whether or not the last sample was OK - true/false.
Schema will look like below:
ThreadGroup
Request_Access_Token
Response Assertion
Response Field to Test: Response Code
Pattern Matching Rules: Equals
Patterns to Test: 200
Regex Extractor // your Access_Token extractor
IfController
Condition: ${JMeterThread.last_sample_ok} // will be TRUE if Response Assertion above is TRUE (i.e. response code = 200)
HttpRequest
// send extracted Access_Token along with request
...

Resources