10 December 2008

How to record HTTP traffic by using JMeter

* JMeter can be download from: http://www.apache.org/dist/jakarta/jmeter/binaries/jakarta-jmeter-2.3.2.zip
* Please use “..\printable_docs\usermanual\component_reference.html” as your reference (in jakarta-jmeter-2.3.2 folder)
* To run JMeter, open .bat file: “..\bin\jmeter.bat”

Just a little overview:
* Test Plan: It is used for permanent store test elements, including settings. It will be saved on you’re your test plan file (.jmx)
* WorkBench: It is used for temporary store test elements. Any element in workbench area will be deleted after JMeter was closed. It is not recommended if you want to save test elements in this area.

JMeter can only access a server in your Local Area Network. For servers in internet area, JMeter can not access them (such as www.google.com).

Let’s start to record

1. Add HTTP Proxy Server element on WorkBench area
# Right click on WorkBench
# Add -> Non-Test Elements -> HTTP Proxy Server
2. Configure HTTP Proxy Server element, set value for Port (it is used for browser configuration) and Optional URL match string (it is used for URL that will be recorded) fields
3. Add Thread Group element on Test Plan area
# Right click on Test Plan
# Add -> Thread Group
4. Configure your IE (Internet Explorer) LAN Connection
# Open LAN Setting page: Click Tool menu -> Click Internet Option menu -> Click Connections tab menu -> Click LAN settings button
# Check Use a proxy server for your LAN (unchecked others setting)
# Fill Address field with “localhost” or your computer name
# Fill Port field with port number of HTTP Proxy Server element
5. Set the Target Controller field with your thread group name
6. Click Start button to start recording HTTP traffic
7. Type the URL (e.g. www.myweb.com) on IE (browser) Link field
8. Pass any steps or “behavior” for the web, and all steps will be recorded on Thread Group element
9. Click Stop button to end the recording
10. Add HTTP Cookie Manager element on Thread Group. This element is used to get session ID
# Right click on Thread Group
# Add -> Config Element -> HTTP Cookie Manager
# It will created on the last of elements, click and drag it to the top of elements

All components will be recorded, including file image, css, js, do, etc. Most of them are used for display only, you can remove/delete them, such as file image, css. But, please don’t remove/delete file .do and .js (or any others file that are related with request/respond data), those files are used for request and respond data

Let’s start to replay…

1. You can add any Listener element to get report of your test plan. For example, add View Result Tree element at the end of element

2. You can add any other element for logic controller on your test plan (we will not use this element for the example)
3. Run the test plan, Click Run menu -> Start (or Ctrl+R)
4. You can look the result of process on View Results Tree element