2

Recording of Jmeter Script Part-2

 2 years ago
source link: https://blog.knoldus.com/recording-of-jmeter-script-part-2/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Reading Time: 4 minutes

In my 1st blog, we come to know about the JMeter.Why should we choose Jmeter for performance testing as it is easier to use. In the 2nd blog, we learn how to record the JMeter request using BlazeMeter extension which was the 1st part of Recording of Jmeter Script. Here in this blog, we will learn the 2nd way of Jmeter request recording-Using Jmeter Proxy.

Recording Using Jmeter Proxy-

Recording HTTP requests is a great way to build test plans. 

  1. It can be useful in creating tests that closely mimic a normal user’s behavior.
  2. Using this method, you can record the front end request as well.
  3. In addition, you can get the responses of the recorded requests in the listeners during the recording.

Prerequisites

Here is a list of the software that requires to record the script:

  • Apache JMeter: Download binaries here
  • Java 6 or later: Download here
  • Mozilla Firefox: Download here

 Steps to Record a Script –

Now let’s move ahead and have a look at the different steps involved in the process of recording browser interactions.

  • Setting HTTP Proxy Server
  • Record Your Activity
  • Run Your Test Plan
  • Save your Test Plan

1. Setting Http Proxy Server- 

Here in this step, we will add the proxy to record the script, now what do you mean by proxy here-

A Proxy is a component that inserts between you and the remote server. It is similar to a man-in-the-middle attack. Similarly, in this case, you are spying on yourself, so you can record browser interactions when your JMeter starts acting like a proxy. It is one of the advanced approaches in software testing to eliminate the complexity of browser interactions.

Now steps to adding proxy in Jmeter

  • Launch the Jmeter and click on the file→ Templates
  • Select the Recording from the select template dropdown.
  • Click on create and add the URL of the website which you want to record.
  • Add the name of the recording JMX and add the Http/Https. By default it is https.
  • Once you click on Create, JMeter creates a bunch of elements required to properly record HTTP and https traffic. 
  • Now HTTP(s) Test Script Recorder has added automatically and it will control the proxy. You just need to enable it by right-clicking on it. There is one listener already added where responses get recorded.
  • With Global Setting, Jmeter works on port no. -8888. So click on the start green button. It will show a popup of Certificate –ApacheJMeterTemporaryRootCA installed in the bin directory of Jmeter.
  • Now open the Mozilla Firefox Network Setting and click on Manual proxy configuration. Add localhost in the HTTP proxy and add port no. 8888. Click on the use of this proxy server for all protocols.

Next, add the ApacheJMeterTemporaryRootCA Certificate in the browser. Click on the certificate setting in the firefox browser and view certificate. Import the certificate from the bin directory of Jmeter.

2. Record Your Activity-

It is a more interesting part of the recording. As you already start the Jmeter Http(s) Test Script Recorder.

  • Now add the URL which you want to record in the firefox browser. 
  • Add the name of the scenario in the JMeter template.
  • Perform the scenario in the browser manually to record in the Jmeter.
  • After completing the recording click on the Stop button in the Jmeter.

3. Run Your Test Plan-

  • In Jmeter, expand the Thread Group –>Recording Controller. Now you can see here so many requests are recorded.
  • Expand the Http(s) test script Recorder and check the responses in the listener.
  • There are other test steps above the thread group. In User-defined variables, variables are generated with values.
  • Now add the no. of virtual users in the thread group.
  • RampUp time and other configuration as per the requirement of the application

4. Save your Test Plan-

  • Add the Listener as View Result Tree in the thread group.
  • Now save the test plan.
  • Click on File –>Save Test Plan as.
  • Save the JMX file in the directory. 
  • Run  the test plan by a green button in Jmeter 
  • It will function exactly like a manually created test.
  • Then you can configure it, delete, and add items to make it match your desired test case more closely.

Conclusion-

Now you are able to use the HTTP(S) Test Script Recorder to assist the creation of JMeter test plans, you should have an easier time creating test plans that mimic realistic scenarios. In conclusion, Feel free to explore the recorded requests in your Recording Controller to learn more about the kinds of requests that are made when users browse your web server.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK