Jmeter - testing multiple urls

岁酱吖の 提交于 2019-11-29 14:09:28

问题


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


回答1:


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}




回答2:


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.

I have named the Thread Group as Demo Test Group.

Step 2: Create a While Controller

A While Controller is created under the Demo Test Group.

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

Step 4: Create a CSV Data Set Config

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

Step 5: Configuring the CSV Data Set.

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.

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

Inside the While Controller create the HTTP Request.

Step 7: Configuring the HTTP Request

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

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

Step 9: Run Test

The last step is to run the test.

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




回答3:


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.



来源:https://stackoverflow.com/questions/16854986/jmeter-testing-multiple-urls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!