Tuesday, 6 May 2014

Record and Play script in JMeter

By the end of this post you will be able to record and Play script in JMeter.  So for recoding we have to do the following:

Add Components:
1. Add Thread Group to Test Plan
    Right click on Test Plan > Add > Threads (Users) > add Thread Group


2. Add Logic Controller to Thread Group
    Right click on Thread Group > Add > Logic Controller > add Recording Controller


3. Add View Results Tree to Thread Group
    Right click on Thread Group > Add > Listener > add View Results Tree


4. Add Script Recorder to Workbench
    Right click on Workbench > Add > Non-Test Elements > add HTTP(S) Test Script Recorder


Browser Proxy Settings:
We need to configure browser to use Proxy, so that JMeter Test Script Recorder can record the events happening on browser. For Firefox

Menu > Options > Advanced (Network tab) > Settings (under Connections)
  •        Select “Manual proxy configuration”
  • ·         HTTP Proxy: localhost and Port: 8080 
  •       Select check-box “Use this proxy server for all protocols



Start Proxy Server on Port 8080:
Start HTTP(S) Test Script Recorder



As we start Script recorder a dialog with Root CA certificate message will appear.
Click OK.


Browse to record the event

 Open up your browser (Firefox, where the proxy is configured),
Open the URL say (www.google.com) you want to record, if you get “Connection Untrusted” message then do the following:

 


Visit the necessary links and do the required actions, all actions will be recorded under 'Recording Controller' node of 'Thread Group'.


Stop the Script recorder


Finally Save your TestPlan.

Play the recorded script
      
      Now select the “View Results tree” and click on Start icon in green to play the recorded script (Ctrl+R)
  
      If test run successfully you will see all executed requests in Green.


No comments:

Post a Comment