The amazing adventures of Doug Hughes

Time for post number 3 regarding Jmeter, and today I will go over simulating users performing searches for keywords feeding from a CSV file. Lets start with a basic test plan, with one thread group, a single web request to google, a random timer, and a results tree listener so we can see what is going on. It should look something like this to begin with (refer to my earlier posts to get to this point, either Jmeter part I or Jmeter part II)

Now you need to create or obtain a CSV file containing your search terms you wish to run through (or users to login, items to view, whatever you would like to change during each request). I made a super simple one here, feel free to download or create your own, and name it searches.csv.

Download a sample searches.csv file.

Now, save that csv file in the same directory that you saved your test plan file. Add a new element as a child of your thread group, called ‘CSV Data Set Config’.

Set the filename to ‘searches.csv’ (or whatever you named your data file), set the Variable Names to ‘TERM’, delimiter to a comma, and stop thread on EOF to false, and sharing mode to ‘All Threads’. The sharing mode just sets the scope of where this variable name (defined as term above) will be available, inside this thread group, inside a single thread, or to the entire test on any thread.

Now we have to tell our individual search to use this CSV data, which is actually really simple to do. Go to your HTTPClient sampler, and in the HTTP parameters list, change the q value, which is currently a string ‘coldfusion’, to ${TERM}.

Now when you save your plan and run it, take a look at your results tree, and click on ‘Request’. You will see that each search sent to google uses the next item from your CSV data file to perform the test.

This is a great technique to use for simulating multiple user logins. Combine this with the cookie manager, and you can fully simulate users logging in, performing a series of actions, and logging out at the end.

Comments on: "Apache's Jmeter Part III – Using a csv to replicate real traffic" (5)

  1. Thank you Chris for the further information. It has been very helpful for me.
    Regards, German.

    Like

  2. Hello,

    Nice article. Too bad all the images are broken in Google Chrome.

    A quick look at the source of the page shows that all img src values have http:// instead of http://

    Cheers,
    Peter

    Like

  3. cpeterson said:

    Thanks Peter, fixed up!

    Like

  4. I’m new to Jmeter.

    I want to configure Jmeter for login purpose of above website ..
    I have used CSV data set configuration to do the same.

    How do i get username & password from CSV file ?
    Is variable namea- comma delimited (TERM) is for both purpose?

    How do i configure and map variable q/en to my CSV file

    Like

  5. Dzmitry Kashlach said:

    Thanks! This approach is very similar to using AccessLogSampler to generate HTTP Requests using text file with set of URL’s

    Like

Comments are closed.

Tag Cloud

%d bloggers like this: