In the previous tutorial, we have seen some basic information on sampler. Here we will try to understand in detail about most commonly used sample which is HTTP Request sampler with example.
Let us now create a plan to test an web page using HTTP Request Sampler. This sampler lets us to send an HTTP/HTTPS request to a web server. If we want to send multiple requests to the same web server, we should consider using an HTTP Request Defaults Configuration Element so that we do not have to enter the same information for each HTTP Request.
Step 1:- Add Thread group to execute the components of the test and configure thread group properties. Refer Thread Group details with example
Right Click on Test Plan -> Add -> Thread ->Thread Group
Step 2:- Add HTTP Request Sampler for this thread. Right Click on Thread Group - Add -> Sampler -> HTTP Request
After adding the request, we need to define the properties for this request as below:
Step 3:- Set the name of the serve that we want to test. Example
google.com, Path as
/about and Protocol[http] as
Step 4:- Add Listener for this thread. Right Click on Thread Group > Add > Listener > View Results Tree. This shows a tree of all sample responses, allowing us to view the response for any sample in the tree. We can also see the time the request took to get this response along with response codes.
Step 5:- Save the Test Plan and Run button or we can use Ctrl + R to run the test
This will make request for the about page (https://google.com/about/) which we can see in the highlighted section of View Results Tree. If we set Path as blank or / then it will make request for (https://google.com/) only.
We can add multiple samplers in the same Test plan like if we want to access the home page and about page of google, just add (https://google.com/) in Server Name and / in Path of one HTTP Request and add (https://google.com/) in Server Name and /about in Path of another HTTP Request.