Reader small image

You're reading from  Master Apache JMeter - From Load Testing to DevOps

Product typeBook
Published inAug 2019
Reading LevelBeginner
Publisher
ISBN-139781839217647
Edition1st Edition
Languages
Right arrow
Authors (3):
Antonio Gomes Rodrigues
Antonio Gomes Rodrigues
author image
Antonio Gomes Rodrigues

Antonio Gomes Rodrigues has been an expert in the field of application performance for more than 10 years. Antonio has significant experience working with load testing tools like JMeter and LoadRunner. He is currently a committer and a PMC member of the JMeter project within the Apache Software Foundation.
Read more about Antonio Gomes Rodrigues

Bruno Demion (Milamber)
Bruno Demion (Milamber)
author image
Bruno Demion (Milamber)

Bruno Demion, better known as Milamber, is a French computer scientist. Since December 2003, he has been working with JMeter to perform load tests in various missions and training courses. He contributes to the JMeter project, in particular on the translation into French of the graphical interface, corrections of anomalies as well as some behaviors (proxy HTTPS, new results tree, icon bar, and so on). He is currently a committer, PMC member and the PMC Chair of the Apache JMeter project within the Apache Software Foundation.
Read more about Bruno Demion (Milamber)

Philippe Mouawad
Philippe Mouawad
author image
Philippe Mouawad

Philippe Mouawad is a technical expert and architect in J2E and web environments in the company Ubik-Ingenierie. He has been using JMeter since 2009. He contributes to the JMeter-Plugins (Redis DataSet, Graphs Generator Listener, and various patches) project. He is currently a committer and a PMC member of the JMeter project within the Apache Software Foundation. He is also a lead developer of the Ubik Load Pack solution.
Read more about Philippe Mouawad

View More author details
Right arrow

Save Our Script

Now, let's start our navigation session.

  1. To do this, simply click the Start button on the HTTP(S) Test Script Recorder element:
    Figure 1.11: HTTP(S) Test Script Recorder
    Figure 1.11: HTTP(S) Test Script Recorder

    Note

    Note that the default listening port of JMeter proxy server is 8888.

    Note the first time you start the recorder, it takes more time as it generates a Certificate Authority that you can use to intercept HTTPS traffic.

  2. This will open a Recorder: Transactions Control window, allowing us to set in real time the name of each recorded step transactions and their grouping based on time:
    Figure 1.12: Recorder: Transactions Control
    Figure 1.12: Recorder: Transactions Control
  3. In this chapter, we will use the Request Parameters example delivered with Apache Tomcat.

    From the browser, navigate to the website:

    http://server:8080/examples/servlets/

    In our case, it will be:

    http://localhost:8080/examples/servlets/

    Here is the first page:

    Figure 1.13: First page of our scenario
    Figure 1.13: First page of our scenario
  4. Then, click on the Execute link of the Required test servlet:
    Figure 1.14: Request Parameters Example with no entries
    Figure 1.14: Request Parameters Example with no entries

    Enter first and last name and click on Submit Query:

    Figure 1.15: Request Parameters Example before submitting query
    Figure 1.15: Request Parameters Example before submitting query

    When the result appears, we can stop our navigation session:

    Figure 1.16: Request Parameters Example after submitting query
    Figure 1.16: Request Parameters Example after submitting query
  5. In JMeter, the scenario tree is the following:
    Figure 1.17: Result of our recording in JMeter
    Figure 1.17: Result of our recording in JMeter
  6. Let us observe what has been recorded:
    Figure 1.18: Observation table
  7. As we can see, thanks to the trick of filling the Server Name or IP and Port Number sections of the HTTP Request Defaults element, these fields remain empty in the HTTP Request elements.

    This will allow us to change the URL and port of the tested site in only one location (HTTP Request Defaults) if necessary (for example, if the script was run on a development environment, and the final test will run on the pre-production environment):

    Figure 1.19: Result of filling in the Server Name or IP and Port Number sections of the HTTP Request Defaults element
    Figure 1.19: Result of filling in the Server Name or IP and Port Number sections of the HTTP Request Defaults element
  8. Similarly, the waiting time between each action (Think time) was recorded:
    Figure 1.20: Recorded think time
    Figure 1.20: Recorded think time
  9. To make it easier to read the results, it is preferable to rename HTTP requests. The automatically chosen name, by default, corresponds to the called URI, but you can control it in the little popup and give it a meaningful name before clicking on the button that will issue the request(s).

    The result of the renaming:

    Figure 1.21: Renaming result
    Figure 1.21: Renaming result
  10. As the last step to the development of the scenario, we are going to add assertions to each HTTP request. These will make it possible to verify that the response received is indeed the expected one.
  11. To do this, select the HTTP request that will receive the assertion, then, via the context menu, choose Add > Assertions > Response Assertion:
    Figure 1.22: Add assertion
    Figure 1.22: Add assertion
  12. A new Response Assertion element has been added as a child to the SC01_1 Homepage request.
  13. Let's select the following options:

    Field to Test: Text Response

    Pattern Matching Rules: Substring (default)

    Patterns to Test: Let's click on the Add button, then insert text contained in the answer:

    Figure 1.23: Assertion configuration
    Figure 1.23: Assertion configuration
  14. To find what data we need to check in response, the trick is to use the View Results Tree element, located under our HTTP(S) Test Script Recorder, by choosing the desired request and then by selecting the tab Response data > Response Body.
  15. We can then copy the text and use Add from clipboard button in the Response Assertion:
    Figure 1.24: Result in Results Tree
    Figure 1.24: Result in Results Tree
  16. Repeat the operation for all the requests in the same way as you did for the home page.

    In the end, we get this JMeter scenario tree:

Figure 1.25: Our JMeter scenario
Figure 1.25: Our JMeter scenario

Now our scenario is ready, let's proceed to the validation of our script.

Previous PageNext Page
You have been reading a chapter from
Master Apache JMeter - From Load Testing to DevOps
Published in: Aug 2019Publisher: ISBN-13: 9781839217647
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (3)

author image
Antonio Gomes Rodrigues

Antonio Gomes Rodrigues has been an expert in the field of application performance for more than 10 years. Antonio has significant experience working with load testing tools like JMeter and LoadRunner. He is currently a committer and a PMC member of the JMeter project within the Apache Software Foundation.
Read more about Antonio Gomes Rodrigues

author image
Bruno Demion (Milamber)

Bruno Demion, better known as Milamber, is a French computer scientist. Since December 2003, he has been working with JMeter to perform load tests in various missions and training courses. He contributes to the JMeter project, in particular on the translation into French of the graphical interface, corrections of anomalies as well as some behaviors (proxy HTTPS, new results tree, icon bar, and so on). He is currently a committer, PMC member and the PMC Chair of the Apache JMeter project within the Apache Software Foundation.
Read more about Bruno Demion (Milamber)

author image
Philippe Mouawad

Philippe Mouawad is a technical expert and architect in J2E and web environments in the company Ubik-Ingenierie. He has been using JMeter since 2009. He contributes to the JMeter-Plugins (Redis DataSet, Graphs Generator Listener, and various patches) project. He is currently a committer and a PMC member of the JMeter project within the Apache Software Foundation. He is also a lead developer of the Ubik Load Pack solution.
Read more about Philippe Mouawad