Recording in JMeter

In this tutorial ,we will study the recording of HTTP or HTTPS requests in JMeter using HTTP(S) Test Script Recorder (or HTTP Proxy Server in older versions of JMeter). Let’s begin with the very first step i.e. launching JMeter. Once, we launch JMeter, we can see the two controls in the left pane –

jmeter
  • Test Plan – Test plan is the area where all the scripting is done and saved.
  • Workbench – Workbench is the area which we use for a temporary purpose, basically it is used for adding test elements that help in recording scripts in JMeter.

Recording in JMeter

Now let’s see how we can record scripts in JMeter-

  1. Add a Thread Group inside the Test Plan and name the Thread Group as per the action they are bound to perform e.g. ‘LoginUsers’.
    Right Click on Test Plan -> Click on Add -> Threads (Users) -> Thread Group
  2. Add a Logic Controller (e.g. Transaction Controller) within the thread group.
    Right click thread group -> Click on Add -> Logic Controller -> Transaction Controller (make sure to click on generate parent sample checkbox).
    Add a transaction controller for each step of the user scenario of the thread group created e.g. transaction controller for “User launch the application”, “User log in with valid credentials”, “Click on the links of unread mails”, “Log out and Exit the application”.
  3. Configure Browser for Proxy SettingsSo, now we have got a skeleton where we can record and create scripts, next thing we will do is to record HTTP or HTTPS requests inside the transaction controllers. For this, we need to setup a proxy in our browser. Although we can record calls with any browser but it is recommended to use Mozilla Firefox just because of its plug-in ‘Firebug’ as firebug is very important for validating whether all calls are successfully recorded or not.
    Steps to set proxy in Mozilla are-
    • Click on Tools-> Options
    • Click on Advanced, under Advanced click on Network tab
    • Click on setting, a connection Settings from would appear
    • Click on Manual proxy configuration radio button
    • Now type 127.0.0.1 in the HTTP Proxy textbox and any available port in Port textbox like 9001Prozy Setting In Browser
  1. Let’s see what we have done, the IP address we have entered in HTTP Proxy textbox is loopback address that is software loopback interface of the machine itself on which we are working and the port we have specified is the Port through which all the traffic will be routed, this port will be used in JMeter also.
  2. Configure JMeter to Record ScriptsNow we will configure JMeter for recording HTTP requests in the transaction controllers –
    • Right click on WorkBench.
    • Click on Add-> Non Test Elements-> HTTP(S) Test Script Recorder(HTTP Proxy server in older JMeter versions).
    • Enter the port value that we have entered in the Port field of our browser.
    • Under Target Controller dropdown select the Transaction Controller in which we want to do the recording.
    • Click on start button to start the recording.recording http request in Jmeter

Now whatever we do in our browser will get saved in the form of http requests in the transaction controller that we have chosen. Suppose, we chose “User launch application” as our target controller then we will click on start button on JMeter then we will go to our browser and launch the application. Again we will go to JMeter and check whether any requests are recorded in the “User launch application” transaction controller or not. If yes then we will click on stop button, chose next transaction controller from the target controller dropdown (User enter valid credentials and click on Login button), click on the start button, go to the browser and enter credentials and click on login button. Go to JMeter and click on stop button. Perform these steps for every transaction controller.

This completes the recording part, next thing is to add Listeners to our Test Plan for interpretation of test results. For this right click on Test Plan-> Add-> Listeners. You will get a list of all the Listeners available, as of now use Aggregate graph and View Result Tree Listeners.
Now we can run the script by pressing Ctrl+R keys or click on Play icon. On top right you will see an icon indicating that the test is running. Once complete, check the results and graphs in the Listeners. Some of the transaction controllers may fail (check in view result tree- failed requests come in red) because lots of scripting is still required in the test plan.

So, this was all about record and playback in JMeter. In the next posts, we will study “Parameterization and Correlation” that are the heart and soul of scripting.

This concludes the recording in the JMeter tutorial, please share it with your friends and colleagues. Check out the complete JMeter tutorial below.

JMeter Tutorial

От QA genius

Adblock
detector