Comparing api request with jdbc values - jmeter

I am doing api request automation using jmeter. i want to compare api request values with jdbc values after execution.how to do that?

Add JDBC driver for your database to JMeter Classpath
Add JDBC Connection Configuration to your Test Plan
Add JDBC PostProcessor as a child of the HTTP Request and execute the relevant query to get the value from the DB and store result into a JMeter Variable
Add JSON Extractor or XPath Extractor as a child of the request and fetch the value from the API response
Compare the values from steps 3 and 4 using Response Assertion
You can see How to Retrieve Database Data for API Testing with JMeter article for reference configuration.

Related

Want to extract data in JMeter

I am using the HTTP request sampler, In which I have used Post Method.
When I Execute the request, it executes the another HTTP request from another thread.
I want to extract the data from that thread because that HTTP request contains the transaction id and I want to use that transaction id in other threads.
The said transaction id is only showing in the pop up message.
Kindly help me.
Solution for the first problem retrieving data from request URL i.e.transaction id using a postprocesser, you can refer the following thread,
Post processer for extracting a value from the URL in the request method.
Solution for the second problem passing the variable from one thread to another,
You need to add a beanshell assertion and set it a property variable like ${__setProperty(transaction_id, ${transID})}
In the second thread group add a preprocesser and accept the property variable.
String tid= props.get("transaction_id");
vars.put("TID",tid);
Thread1:
Thread2:
JMeter can only extract data from response body, message, code, headers, or URL.
If you send the request which triggers another request and the data you're looking for is not in the 1st request response scope - unfortunately you won't be able to get it.
The only option I can think of is using WebDriver Sampler which provider JMeter integration with Selenium browser automation framework so you would be able to execute the request and get the data from the popup using real browser.
WebDriver Sampler can be installed using JMeter Plugins Manager

how can we pass bearer token created in xml into 2 nd api which is placed in another thread group in jmeter

how can we pass bearer token created in xml into 2 nd api which is placed in another thread group in jmeter I have tried with set property but it is not working as the body of token is in xml.
If your token comes in the XML response just extract it using XPath Extractor or better XPath2 Extractor.
Once you have the token stored as JMeter Variable there will be 2 options:
Convert it into a JMeter Property using __setProperty() function
Or use Inter-Thread Communication Plugin (see SynchronizationExample.jmx test plan for reference usage)

Jmeter - How to extract JSON response data and assign those to cookie?

I want to extract json response data and assign them to next request cookies. Can anyone help me with this.
Thanks in advance.
You can extract the required value from JSON using JSON Extractor. See Jayway JsonPath - Getting Started to learn more about JSONPath.
Once you have a JMeter Variable holding the value you can use HTTP Cookie Manager to configure JMeter to send an extra cookie.

JMeter: How to use the RESTful API key for authorization of the next set of API

I am creating a jmeter load test plan for RESTful API request. I need to use the dynamic API key generated in my first sampler SignIn API in the next set of API requests I am going to create.
Can someone help out with how to pass the selected data parameters from response and input to the another api request in other required format for that post request.
Response Header
WebxxxHeader: {"UserName":"xxxxx","UserID":1,"ApiKey":"ea9a3572-de75-4a85-848a-8fed874f2269","ValidFrom":"2015-06-05 05:54:35","ValidTo":"2015-06-12 05:54:35","UserRole":null,"Password":null,"DeviceToken":null,"DeviceType":null,"IsRetina":false,"UniqueId":null}
Header to be posted in the next set of APIs
WebxxxHeader: {"UserName":"xxxxx","ApiKey":"ea9a3572-de75-4a85-848a-8fed874f2269"}
One more issue here is I have to pass the user email in the header instead of UserName.
Please share advanced JMeter blog references.
Thanks in advance for your suggestions.
I would suggest searching the web for something like "JMeter correlation" - that should give you the answers you're looking for.
Particular this API key bit can be handled via Regular Expression Extractor postprocessor.
Add Regular Expression Extractor as a child of the request which returns the API Key
Configure it as follows:
Field to check: Response Headers
Reference Name: anything meaningful, i.e. API_KEY
Regular Expression: "ApiKey":"(.+?)"
Template: $1$
Other fields can be left as is
Add HTTP Header Manager as a child of the second request and configure it as follows:
Name: WebxxxHeader
Value: `{"UserName":"xxxxx","ApiKey":"${API_KEY}"}
If you testing REST API I think that JSON Path Extractor available via JMeter Plugins could be extremely useful. See Using the XPath Extractor in JMeter guide (scroll to "Parsing JSON") for installation and usage instructions and some form of JSON Path language reference.

JMeter not recording an ADF application

I am following the below link to configure JMeter for Oracle's ADF 11g. I am not able to record the ADF Application deployed on WebLogic Server ver 10.3.6 using JMeter 2.10. My JDeveloper version is 11.1.2.4.
http://one-size-doesnt-fit-all.blogspot.com.au/2010/04/configuring-apache-jmeter-specifically.html
The document looks good but I see some weird Test Plan structure. I would suggest to do the following:
Record your use case via JMeter HTTP Proxy server
When you'll get set of "interesting" HTTP requests you'll need to deal with dynamic values as it's described in the guide. The key point is that Regular Expression Extractor is a Post Processor so it must be a child of HTTP Request.
JSESSIONID cookie is handled by HTTP Cookie Manager, there is no need to append it to the URL. Just make sure that you have CookieManager.save.cookies=true property. It can be found in jmeter.properties file under /bin folder of your JMeter installation.
So you need to implement next steps:
Record some HTTP Requests
Extract viewstate and other dynamic stuff from first request via Regular Expression Extractor Post Processor and save it as JMeter Variables
Use variables instead of recorded hard-coded values
You can inspect requests and responses via "View Results Tree" listener, it's able to demonstrate request and response headers, cookies, timings, etc. and response data to assure that you've reached desired page in your flow.
Hope this helps.

Resources