Monday, November 24, 2014

How to record test script in JMeter and run through command line?

Below are the steps to record test scripts using JMeter

1. First launch your JMeter app, right click on the "Test Plan" node, select "Add" -> "Threads (Users)" -> "Thread Group"


2. Select "Thread Group" node and right click. Select "Add" -> "Config Element" -> "Http Request Default"


3. In "HTTP Request Defaults" page, enter the value in "Server Name or IP" field. For example, "jmeter.apache.org".

Note: If your portal are using SSL, please enter "443" to the port. The "Path" field can leave it as an empty field.


4. Select "Thread Group" node and right click. Select "Add" -> Logic Controller -> "Recording Controller".



5. Select "Workbench" node and right click. Select "Add" -> "Non-Test Elements" -> "HTTP(S) Test Script Recorder".

6. In "URL Patterns to Include" section, add the value ".*\.html".



Note: Make sure "Target Controller" is selected. Should select the the "Recording Controller" that have created in "Test Plan".

7. Select "HTTP(S) Test Script Recorder" and right click. Select "Add" -> "Listener" -> "View Results Tree"


8. Click on the "HTTP(S) Test Script Recorder", click on "Start" button. "Root CA certificate: ApacheJMeterTemporaryRootCA created in JMeter bin directory" message is displayed.

Configure browser to use JMeter proxy

1. Open the "Chrome", click on the "Setting" menu. Click on "Change Proxy Settings" button in the "Network" section.

2. Click on "LAN settings" button, set the value as Address: localhost Port: 8080


3. Open the Chrome browser and type in the command as "http://jmeter.apache.org/", the activity request will be captured at jmeter tools.


4. Make sure the "Recording Controller" consists of the intercept request. Click on "File" -> "Save Test Plan as" to save the test plan in jmx extension.



5. Run the jmeter test script through the command line as described below. Assume the test plan file name is "jmeter.jmx"
jmeter -n -t jmeter.jmx
Install SSL certificate browser to intercept the request

1. When the JMeter tool is started, a temporary SSL certificate "ApacheJMeterTemporaryRootCA.crt" will be generated. It always located at [JMETER_HOME]\bin.

2. Import the certificate "ApacheJMeterTemporaryRootCA.crt" into browser.



No comments: