Recording Jmeter Scripts behind a proxy server

Recording Jmeter Scripts behind a proxy server

In one of the blog we saw the steps of recording Jmeter scripts using a proxy server.

JMeter has its own in-built Proxy Server, the HTTP(S) Test Script Recorder. This is only used for recording HTTP or HTTPS browser sessions as explained in below link.


The above steps will work properly if the internet connection is not behind a proxy and can be accessed directly.
If we are testing from behind a firewall/proxy server or if we the internet access is provided using proxy server then the above steps will fail and will not record any of the steps.
Steps to record in Jmeter if the internet is accessed via proxy:
1.      Start Jmeter with the firewall/proxy server hostname and port number.
To do so, Open a command prompt in windows and run the jmeter.bat file from a command line with the following parameters:
-H [proxy server hostname or ip address]
-P [proxy server port]
-N [nonproxy hosts] (e.g. *.apache.org|localhost)
-u [username for proxy authentication - if required]
-a [password for proxy authentication - if required]
Example: jmeter -H comproxy.server -P 8080 -u username -a password -N localhost
You can also use --proxyHost, --proxyPort, --username, and --password as parameter names
2.      In this exercise instead of recording under WorkBench, let us record the requests under TestPlan. Once the Jmeter is launched
Add Thread Group under Testplan by following the steps as
Right Click on Test Plan -> Add -> Threads (Users) -> Thread Group

3.      Now Right Click on WorkBench -> Add -> Non-Test Elements -> HTTP(S) Test Script Recorder

4.      Under Global Settings of HTTP(S) Test Script Recorder provide the port as 6500.
Note: Here we are setting proxy which is only used for recording HTTP or HTTPS browser sessions. This is not to be confused with the proxy settings described above, which is used when JMeter makes HTTP or HTTPS requests itself.
Change the Target Controller to “Test Plan -> Thread Group”
Also Select the Grouping as “Put each group in a new transaction controller”


5.      Now we need to change the proxy setting of our machine to records using the proxy port 6500. To perform the steps:
Open IE - >Internet Options -> Connections -> Lan settings
Under Proxy Server, Enter Address as “localhost” and Port as “6500” and click OK




6.      Now in Jmeter Click on “Start” under HTTP(S) Test Script Recorder. Once we click on start a message will be displayed as below:


In Jmeter/bin directory a certificate will be present.
7.      Now go to IE and open the required webpage to record.  For example, open www.google.com
8.      If the certificate is successful and has now issue, the steps will be recorded as shown below:


Some times if recording for the first time using Jmeter proxy we will get an error for certificate as “There is a problem with this website's security certificate.”. In that case we need to import the certificate from step 6 to the Internet Options -> Content -> Certificates and Import the correct certificate.
Once recording of the required steps are completed, stop the HTTP(S) Test Script Recorder.

Also change the proxy settings to the original settings to access internet.

Comments

  1. This is what i am looking for since long time for my project. Thanks for your help it will very use full for my semi dedicated proxies project which is based on proxy server.

    ReplyDelete
  2. Thank you so much.... I was looking for this since long time.... Really appreciated

    ReplyDelete
  3. if you change your proxy, how can you get access to external websites? I am testing behind a proxy and trying to record non internal website. Does your advice relate to testing local/internal sites?

    ReplyDelete

Post a Comment

Popular posts from this blog

Steps to Analyze AWR Report in Oracle

Vmstat Output explained

Verifications and Error Handling in LoadRunner *Web_reg_find and Web_reg_save_param*