Samplers
Samplers in JMeter are added as child of Thread Groups. These are used to send different types of request to server. Once, the sampler request is processed by the server, its response is returned to JMeter and the same can be viewed and analyzed in terms of different performance parameters like response time, Hits per second, throughput etc.
We can launch the Samplers in JMeter by following the path-
We can launch the Samplers in JMeter by following the path-
step 1 : Right Click on Thread Group
step 2: navigate to Add Sampler
step 3 : Click on the required Sampler
We have many samplers but in real time we will use only few samplers .
So Now we will disucuss about those samplers. Those are
HTTP Request - Used to send HTTP/HTTPS requests to server. This is the most widely used sampler for testing Web based applications.
JDBC Request - Used to send SQL queries to a database server.
SOAP/XML-RPC Request - Used to send SOAP requests to a SOAP web service.
Flow control Action - This is special type of Sampler, which doesn't send a request to the server instead it is used to introduce pauses in a test.
FTP Request - Used to send file put and get requests to an FTP server.
Apart from the above defined samplers, there are additional list of samplers provided by Jmeter- AJP/1.3 Sampler , Access Log Sampler , BSF Sampler ,BeanShell Sampler , Debug Sampler , JMS Point-to-Point,JMS Publisher ,JMS Subscriber,JSR223 Sampler,JUnit Request, Java Request,LDAP Extended Request,LDAP Request,Mail Reader Sampler,OS Process Sampler ,SMTP Sampler,TCP Sampler ,Test Sampler , WebService (SOAP) Request
In case If are selected the sampler as HTTP request then interface look like the following screenshot.
Configeration inside of HTTP request with an example:
Now i am going to build a HTTP request for one API.
The body of the above API is
{
"name": "PTO Name",
"organizationName": "RIL",
"organizationId": "01",
"email": "pto@girmiti.com",
"state": "Karnataka",
"city": "Bangalore",
"country": "Indian",
"contactDetails": {
"name": "ABCD",
"phone": "+9198459845",
"email": "contact@girmiti.com"
},
"siteURL": "http://www.test.com",
"status": "<Opional>"
On successful request, the API would return the below response
{
"statusCode": "0",
"statusMessage": "SUCCESS",
"ptoId": "01"
}
Now we will see how to build the HTTP request .
Before going to build the request validate that API in postman tool either it is returing the expected output or not.
step 1: open jmeter
step 2 : change the name to test plan or keep the same
step 3 : right click on test plan and add thread group
step 4 : now right click on thread group and choose sampler as HTTP request.
Now the above screen shot will appear to you.
Name : you can enter any meaning ful name
comment : u can enter any or you can leave
Protocol (HTTP) : If you are following http then leave the box empty ifnot enter https in the box.
IP Address : 192.168.0.181 ( see above API )
port name: 9080
method : identify the method name from postman for the perticular API
path : /coreservice/afcservice/core/1/0/createPTO
Parameters : If you want to declare or pass any name / passwords you can pass from here.
Just hit on add tab at the bottom and add as you required.
Body data: copy the body data of the request from the postman and peaste the same hitting on body data.
Files upload: If you wanna upload any files you can upload here.
No comments:
Post a Comment