Tuesday, March 23, 2010

Tip #11: Template for JMeter's recording proxy

If you often need to use JMeter's recording proxy you can save your time by using templates for HTTP request filtering. Just add HTTP Proxy Server element to Workbench, than add regular expressions for URLs of your site like www\.example\.com.* to "URL Patterns to Include" list, add regular expressions for exclusion of some static HTTP requests like .*\.css$ to "URL Patterns to Exclude" list and save this template using "Save Selection As..." item of HTTP Proxy Server's context menu.



Next time you can just open this file in JMeter and you will have ready for work recording proxy.

34 comments:

  1. Thanks for share you knowledge. I find you tips very helpful.

    I need you help in load testing.

    I am beginner level developer, I am test a site for load testing.Eventhing is fine I am quite comfortable with Jmeter, Recording testcases, using parametrized variables and running test plans.
    but I am confused about multiple users,

    The application I am testing is having mock tests which have 100 question with multiple choices, User can answer questions/ move to next Q/previous Q / select a choice are ajax calls. Total time for
    test is 8100 seconds
    I am taking an average test case where a user goes to next Q 150 times /previous Q 50 times /select choice 100/ change choice 50 times which makes around 350 hits.
    As i have 8100 sec to finish the test that means 8100/350 = 23 secs per hit now I have add a Gaussian Timer with Deviation of 5s and constant time 18s.

    if I am running this test with hundred user it is
    taking 6-7 hours to finish.


    Can Your Please help to find out which timer and how much think time i need to use to get proper results

    ReplyDelete
  2. I usually use timer values based on the real time user need to do some action, e.g. if user needs 5-7 seconds for authentication I add 5-7 seconds variable timer. Please look my previous post: Tip #3: Pauses in test plan

    ReplyDelete
  3. My system: win7 and 32 bit

    i have download jemter from http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi

    then i unzip that put that in C:\ drive

    and move to bin and double click on jmeter.bat


    then i got the following error :
    ===========================
    unable to access jarfile apachejmeter.jar

    error level 1

    Press any key to continue
    ==============================
    then when i press any key it just shut down

    what is solve for this problem ?

    thank you

    ReplyDelete
  4. Niloy, I've just tested on win7 64bit and it works without any problem. Try to run it by the following command (from the bin directory):

    java -jar ApacheJMeter.jar

    ReplyDelete
  5. Hi Victor,

    I have the same problem as Niloy when trying to run jmeter.bat file. And I can't find ApacheJMeter.jar anywhere. I've installed JRE on my computer and don't know why Jmeter does not work at all :(

    Do you have any solution? Thank you.

    ReplyDelete
  6. Anonymous, here is the link: http://www.apache.org/dist//jakarta/jmeter/binaries/jakarta-jmeter-2.5.1.zip
    Download and unzip. It contains "jakarta-jmeter-2.5.1\bin\ApacheJMeter.jar"

    ReplyDelete
    Replies
    1. Perfect. It also worked for me. thanks

      Delete
  7. Thank you so much Victor. It works :D

    ReplyDelete
  8. Thanks, Victor
    You are an inspiration to NEW Jmeter professionals

    God Bless you with a great successful years ahead

    Kumar

    ReplyDelete
  9. I victor I really appreciate your Jmeter tips. We are just started to leverage Jmeter more in our group to stress test new features before promoting to production. I have one case where we want to use the proxy recorder to capture the click stream of a few of our pages. However we don't want to include external site URLs. Since there are a bunch of these we thought we would just use the include filter instead of trying to find and exclude all the external URLs.

    In our case we would want to include the internal URLs like http://*.example.com/*

    I don't know regex so I was curious what the regex would look like for this. I see your example above if we include www would be www\.example\.com.*

    I tried *\.example\.com.* and .*\.example\.com.* but both were incorrect. Any chance you can help me with this?

    Thanks so much!

    -Jonathan

    ReplyDelete
  10. Jonathan,
    .*\.example\.com.* is the correct regexp for you. I've just checked it in JMeter 2.5.1 and it worked well. If this will not work for you probably the problem is in another place.

    ReplyDelete
  11. Thanks for your quick response! You are right, the regex was fine. The problem is with using the 'Retrieve All Embedded Resources from HTML Files' option on the proxy server. It doesn't seem to honor the include/exclude filters and will include requests from other domains. Have you ever noticed this behavior?

    ReplyDelete
  12. Jonathan,
    "Retrieve All Embedded Resources from HTML Files" option does not affect on include/exclude filters. It just turns on/off the corresponding option in recorded HTTP samples.

    ReplyDelete
  13. If that is the case is it expected behavior to get requests for connect.facebook.net or doubleclick when we explicitly exclude these domains in the exlude filters? It only happens when I check the include the embedded resource checkbox.

    ReplyDelete
  14. Jonathan,
    Exclusion/inclusion filters (in recording proxy) work only during test plan writing. If you turn on "Retrieve All Embedded Resources from HTML Files" option you need to use match filters in HTTP samples.

    I prefer not to use "Retrieve All Embedded Resources from HTML Files" option. Instead of this I add all static HTTP samples during the test writing and exclusion/inclusion filters can help me. But in most cases I do not add static HTTP samples to the test plan at all.

    ReplyDelete
  15. I have a question about the exclusion filter of the static HTTP requests such as .css and .png

    Example: I want to test the performance of the homepage of a site; www.example.com/index.html This site has a css file: www.example.com/styles.css and some image: www.example.com/image.png When recording with the proxy, these files are not recorded as seperate requests if I add those URL patterns to exclude like in your example. But are these files received when I run the final test plan? If the css is a very large file, this will affect performance of that page.

    ReplyDelete
    Replies
    1. Victor, in your case JMeter will request css/images/etc. files only when you check "Retrieve All Embedded Resources from HTML Files" option in HTTP Request settings. Anyways you can monitor what's exactly requested using "View Results Tree" listener. Just add it to the Thread Group you want to monitor and and start the test.

      Delete
  16. Hi Victor.

    I am new to this JMeter. Can you give me the detail explanation about graph result. i am not able to analysis the graph result. how can i analys and get conclude from the graph which i got..

    Please explin anyone. Thanks in advance.

    ReplyDelete
    Replies
    1. The answer to your question is the material for the big article.

      Delete
  17. Hi Victor,

    I tried to exclude the image file while recording by adding .*\.gif to the url patterns to exclude, but i can still see that image appears in my recorded script...could you please inform me why??? what am i doing wrong?

    ReplyDelete
    Replies
    1. Try .*\.gif$ instead of .*\.gif

      Delete
    2. Hi Victor,
      I am facing the same problem as well and applied both solutions i.e. .*\.gif$ instead of .*\.gif and still these are not working, any other solution?

      Thanks in advance

      Delete
    3. I've just doublechecked in JMeter 2.6 - is works as expected. Please provide me with the URL of the page where you are not able to filter gif's.

      Delete
  18. Hi Victor,

    I am just confused whether to exclue gif, bmp, js etc. The site that I am going to record is a site where we search for products(displayed as images), then drag and drop these images to a empty area(board) and save the board.

    This is the first time I am using Jmeter, should i:
    1> exclude all static content like .images, .gif. .js, .css
    2) should I use 'Retrieve all embedded resources option' incase above step should be done.


    Please advise what needs to be done in order to get correct response time.

    Thanks & Regards,
    Jackson

    ReplyDelete
    Replies
    1. 1) if your static files are really static (are not returned by script) then you can (and probably must) exclude them.
      2) IMHO you should not use this option except some special cases.

      Delete
  19. hi Victor..... i am using jmeter from past 3 month . i am facing some problem while recording...i just want to exclude .css and .js and include only html and text file i have tried the things in u blog.....but it is not working for me ....... i am recording my script from this url http://xxx.xxxx.com.au/xxx/performAction? for this url how should i can include the text,html and exclude .css,.js ....................

    thanks in advance ..............

    ReplyDelete
    Replies
    1. There is Content-type filter on the Recording Proxy settings panel. You can specify "(text/html|text/plain)" (excluding the quotes) in Include textbox to record only text and html.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. hi Victor .....i have did what you said and in url pattern to exclude i have given regular expression (.*\.js , .*\.css )after this also i seem this js and css are still recording ....... can u please tell me how to exclude this kind of url pattern ........... thanks for the previous reply ....................and thank in advance...........

      Delete
    4. the url look like this /xxxx/css/core.css,/css/grid.css,/css/common.css,/css/external/supernote.css and js url looks like this ./javascript/core/json.js,/javascript/core/window.js,/javascript/core/shortcut.js

      Delete
    5. Did you try to add $ character to the end of your regular expressions?

      Delete
  20. Scenario :

    1 user will login
    2 search
    3 if result exits it will return that row else it will return message


    when i record this scenario through proxy in the view result tree,request and response are showing correctly but when the same thing I run directly in the view result tree list for the same request sub request are showing and in the response tab wrong data are showing and for that reason assertions are not working during running the test case.

    This application is Ajax+json based, so can anyone suggest how to overcome this situation.

    ReplyDelete
  21. @victor can u please reply to my post posted on 29th june,help needed.

    ReplyDelete
    Replies
    1. That's a difficult question without a specific data (test plan, response example, etc.)
      But in general I think the first thing you should check are cookies (compare the cookies sent by your browser and JMeter).

      Delete