Get Knowledge from Video instead of Content:

Monday 30 January 2017

JMeter - Config Element - "HTTP Request Defaults"

"HTTP Request Defaults" is a very basic and key element of JMeter. This config element is used when all requests in your JMeter script are being sent to the same server. You can add a single HTTP Request Defaults element under Test Plan with the proper server name or IP address in the field "Server Name or IP". Now, when you add HTTP Request controllers, then leave the "Server Name or IP" field empty. The controllers will inherit this field value from the HTTP Request Defaults element. Make sure you have provided correct method type in each HTTP Request. 

Let’s understand this with one example. I have 4 pages with common URL http://perfmatrix.blogspot.in

I have added HTTP Request Defaults under Test Plan:


Then added all the HTTP Request Samplers like this:




The Result is:

Advantages:
1. It makes JMeter script simple and easily maintainable. If server name or IP changes, then you do not need to change those details in each HTTP Request. Just make changes in HTTP Request Defaults and that will be applicable for all the HTTP Requests.
2. It reduces the chances of missing the URL/port changes from HTTP Requests
3. It also avoids data duplication

How to add "HTTP Request Defaults" element?
You can follow below steps to add HTTP Request Defaults:
1. Select "Test Plan" node
2. Right click on "Test Plan" node
3. Mouse hovers "Add"
4. Mouse hovers "Config Element"
5. Click "HTTP Request Defaults" 

How to remove "HTTP Request Defaults" element?
You can follow the below steps:
1. Select "HTTP Request Defaults" node
2. Right click on "HTTP Request Defaults" node
3. Click "Remove" (Mouse) or "Delete" button from the keyboard
4. Click "Yes"  

What are the attributes of "HTTP Request Defaults" element?

"HTTP Request Defaults" has below attributes:
  • Name: To provide element name
  • Comments: To provide arbitrary comments (if any)
  • Server Name or IP: Domain name or IP address of the web server without including prefix http://
  • Port Number: Port number of Web-server
  • Connect: Number of milliseconds to wait for a connection to open.
  • Response: Number of milliseconds to wait for a response
  • Implementation: Java, HttpClient3.1, HttpClient4. If not specified the default depends on the value of the JMeter property jmeter.httpsampler, failing that, the Java implementation is used.
  • Protocol [http:]: Either http or https (Do not use ://)
  • Content Encoding: The encoding to be used for the request
  • Path: It is a path to the resource. You can keep it blank.
  • Send Parameters With the Request: The query string will be generated from the list of parameters you provide. Each parameter has a name and value. The query string will be generated in the correct fashion, depending on the choice of "Method" you made.
  • Server (proxy): Hostname or IP address of a proxy server without http:// to perform the request. 
  • Port: The port number of the proxy server 
  • Username(Optional): username for the proxy server.
  • Password(Optional): password for the proxy server.
  • Retrieve All Embedded Resources from HTML Files (Advanced): Allow JMeter to parse the HTML file and send HTTP/HTTPS requests for all images, Java applets, JavaScript files, CSSs, etc. referenced in the file.
  • Embedded URLs must match: If present, this must be a regular expression that is used to match against any embedded URLs found.
          Next Topic:
          Apache JMeter - "Java Request Defaults" Element

          Previous Topic:
          Apache JMeter - "HTTP Header Manager" Element

          Related Topics:

          No comments :

          Post a Comment