Jmeter03:发送post请求参数化
在用Jmeter发送post请求时,我们经常会碰到变更参数的情况,不可能每次都在HTTP请求那里去改参数,那太麻烦了,然后我们的参数化就派上了用场,那么如何进行参数化呢?
首先进行单个变量的参数化:
Step 1:添加csv数据文件设置
![](http://upload-images.jianshu.io/upload_images/11813766-9c9438da80c58051.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
Step 2:创建并编辑csv文件。
创建一个csv文件,用记事本或者excel或者wps打开进行编辑均可。
![](http://upload-images.jianshu.io/upload_images/11813766-768ca92f2e1fdd9f.png?imageMogr2/auto-orient/strip|imageView2/2/w/1025/format/webp)
在这里我对accesstoken进行参数化
Step 3:csv在数据文件设置中进行相应填写,文件名自行根据路径浏览。
![](http://upload-images.jianshu.io/upload_images/11813766-5b70f1d6f753fe09.png?imageMogr2/auto-orient/strip|imageView2/2/w/1092/format/webp)
image.png
Step 4:在HTTP请求中对变量内容参数化
![](http://upload-images.jianshu.io/upload_images/11813766-d2e50bc415e18324.png?imageMogr2/auto-orient/strip|imageView2/2/w/1092/format/webp)
image.png
线程组中对线程数进行修改
![](http://upload-images.jianshu.io/upload_images/11813766-1369d89e490d8ab8.png?imageMogr2/auto-orient/strip|imageView2/2/w/1092/format/webp)
image.png
Step 5:运行,查看结果。
![](http://upload-images.jianshu.io/upload_images/11813766-e22f0f6694cca9f0.png?imageMogr2/auto-orient/strip|imageView2/2/w/1092/format/webp)
image.png
在网页中进行查看
![](http://upload-images.jianshu.io/upload_images/11813766-96c9463842ef0a0b.png?imageMogr2/auto-orient/strip|imageView2/2/w/909/format/webp)
image.png
网页中进行查看
![](http://upload-images.jianshu.io/upload_images/11813766-701b37a654bd1309.png?imageMogr2/auto-orient/strip|imageView2/2/w/700/format/webp)
image.png
![](http://upload-images.jianshu.io/upload_images/11813766-50c2d9237a5e010d.png?imageMogr2/auto-orient/strip|imageView2/2/w/663/format/webp)
image.png
成功模拟多个用户进行post请求。
接下来我们进行多个变量的参数化,只需要进行小小的改动,我以2个为例:
Step 1:同上。
Step 2:创建并编辑csv文件。
![](http://upload-images.jianshu.io/upload_images/11813766-0add0fd58d6b19ab.png?imageMogr2/auto-orient/strip|imageView2/2/w/1025/format/webp)
image.png
Step 3:csv在数据文件设置中进行相应填写,文件名自行根据路径浏览。
![](http://upload-images.jianshu.io/upload_images/11813766-0f95718ea8e6723f.png?imageMogr2/auto-orient/strip|imageView2/2/w/1092/format/webp)
image.png
Step 4:在HTTP请求中对变量内容参数化
![](http://upload-images.jianshu.io/upload_images/11813766-e34aabc684bfbd6f.png?imageMogr2/auto-orient/strip|imageView2/2/w/1092/format/webp)
image.png
Step 5:运行,查看结果。
![](http://upload-images.jianshu.io/upload_images/11813766-bcfa3fc9b12ba384.png?imageMogr2/auto-orient/strip|imageView2/2/w/1092/format/webp)
image.png
查看网页
![](http://upload-images.jianshu.io/upload_images/11813766-7e6b71c81a1a7d26.png?imageMogr2/auto-orient/strip|imageView2/2/w/798/format/webp)
image.png
![](http://upload-images.jianshu.io/upload_images/11813766-57cf50d6c055136f.png?imageMogr2/auto-orient/strip|imageView2/2/w/628/format/webp)
image.png
![](http://upload-images.jianshu.io/upload_images/11813766-c0cda078d898709c.png?imageMogr2/auto-orient/strip|imageView2/2/w/623/format/webp)
image.png
![](http://upload-images.jianshu.io/upload_images/11813766-d0c6c1d37fe8fa21.png?imageMogr2/auto-orient/strip|imageView2/2/w/636/format/webp)
image.png
![](http://upload-images.jianshu.io/upload_images/11813766-57fb2c33d7d1954f.png?imageMogr2/auto-orient/strip|imageView2/2/w/590/format/webp)
作者:我的世界星辰大海
链接:https://www.jianshu.com/p/4a27ac4052c7
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
,博客记录生活,技术改变生活