15

I'm new to Jmeter; I would like to know how to test multiple urls (stored in a txt/csv file) of different sections of a website in a load test ie. is there any way to import that file and run a load test or any alternative solution?

Thanks!

LP

L P
  • 1,776
  • 5
  • 25
  • 46

3 Answers3

57

This is how I did it. I have explained it step by step so that any newbie does not have to go through all the documents of Jmeter for figuring it out.

Step 1: Create a Thread Group.

enter image description here

I have named the Thread Group as Demo Test Group.

Step 2: Create a While Controller

enter image description here

A While Controller is created under the Demo Test Group.

Step 3: Create a new variable named path in the condition section.

enter image description here

Step 4: Create a CSV Data Set Config

enter image description here

The CSV Data Set config is created inside the While Controller.

Step 5: Configuring the CSV Data Set.

enter image description here

Make the changes as highlighted in the box. Inside the Filename section enter the csv file location.

The CSV file location should contain only the path. This is how my CSV file looked.

enter image description here

The value inside the Variable Names is same as the name of the variable in While Controller. Which is path.

Step 6: Create HTTP Request

enter image description here

Inside the While Controller create the HTTP Request.

Step 7: Configuring the HTTP Request

enter image description here

I have enter the Domain Name, the Protocol and in the Path section entered the variable {path}, which is picked from the CSV file.

Step 8: Add View Results Tree

enter image description here

You need to add the Listener under HTTP Request. Its purpose to listen to the responses.

Step 9: Run Test

enter image description here

The last step is to run the test.

You can see that the responses is been collected inside the View Results Tree.

Rito
  • 3,092
  • 2
  • 27
  • 40
  • Thanks a lot! Even though, I had different configuration (I did not use while controller), but your pictures helped me! – Yan Khonski May 19 '20 at 14:58
  • I have another component after while controller. But next component is not being executed as I am getting below exception: __2021-02-24 20:23:29,317 INFO o.a.j.t.JMeterThread: Stop Thread seen for thread Thread Group 1-1, reason: org.apache.jorphan.util.JMeterStopThreadException: End of file:C:/Users/Administrator/Downloads/jmeter/urls.csv detected for CSVDataSet:CSV Data Set Config configured with stopThread:true, recycle:false__ – prateek goyal Feb 25 '21 at 04:24
  • In path field for me the variable is not being replaced. It's working fine if I want to use it in "Parameters" section, but not if directly want writing the varible into the Path field. – ktamas Jul 25 '22 at 11:46
5

Use the JMeter StringFromFile function.

A very simple example: read from a file c:/tmp/snip.txt into a jmeter variable myVar.
Add a User Defined Variables config element to your test plan:

  • name: myVar
  • value: ${_StringFromFile(c:\tmp\snip.txt,myVar,,)}

Then use the variable as ${myVar} in your requests.

Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90
Dan Seibert
  • 310
  • 2
  • 4
4

Use CSV DataSet element which will on every iteration of main loop extract one line and put in the variable you will name.

Then put the var in path field of httpsampler. If your var is named url, then you will put ${url}

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • I think it's working fine using the instructions provided but I just want to confirm if what I've done is correct: STEP1. Create Test plan -> thread grp - thread grp -> Home page with IP - -> Login page with user, pwd ; path set to http://../submit_login/ - -> Changes page with path set to ${url} STEP 2: Test plan -> CSV data set config -> filename (loadtest_urls.csv), variables names: url --- Run --- I see results in the graph but I'm not sure how to interpret them. – L P Jun 06 '13 at 15:35
  • What you did seems fine, you will need to read the manual: http://jmeter.apache.org/usermanual/index.html also look at http://sqa.stackexchange.com/questions/2546/where-can-i-find-good-jmeter-tutorials , you can also upvote :-) – UBIK LOAD PACK Jun 06 '13 at 20:49