Jmeter - testing multiple urls

2019-02-07 04:52发布

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

3条回答
何必那么认真
2楼-- · 2019-02-07 05:03

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.

查看更多
女痞
3楼-- · 2019-02-07 05:08

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.

查看更多
再贱就再见
4楼-- · 2019-02-07 05:11

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}

查看更多
登录 后发表回答