Jmeter:Excel上载,在下一个请求中传递的硬编码参数 [英] Jmeter: Excel Upload, hard coded parameters passing in next request

查看:454
本文介绍了Jmeter:Excel上载,在下一个请求中传递的硬编码参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经记录了一个Jmeter脚本,其中上载了具有4条记录的excel,并且在下一个请求中,将excel中的4个值作为不同的参数传递. 但是当我更改excel/no时.的值更改为100.请求如何采用excel的新值.

I have recorded a Jmeter script where an excel with 4 records has been uploaded and in the next request the 4 values in the excel are passed as different parameters. But when I wil change the excel/no. of values changed to 100. How the request will take the new values of excel.

由于将有100多个记录,并且记录数未知,因此无法进行参数化和关联.

As there will be more than 100 records and the record count is not known, so parameterization and correlation is not possible.

请帮助.

推荐答案

如果您有Excel(test.xlsx名称下的="nofollow noreferrer"> xlsx )文件,您可以使用以下方法动态填充请求参数:

If you have Excel (xlsx) file under name of test.xlsx in "bin" folder of your JMeter installation you can dynamically populate request parameters using the following approach:

  1. tika-app.jar 添加到 JSR223预处理器添加为您要参数化的请求的子代
  2. 将以下代码放入脚本"区域:

  1. Add tika-app.jar to JMeter Classpath
  2. Restart JMeter to pick the .jar up
  3. Add JSR223 PreProcessor as a child of the request you want to parameterize
  4. Put the following code into "Script" area:

def workbook = new org.apache.poi.xssf.usermodel.XSSFWorkbook(new File("test.xlsx"))
def sheet = workbook.getSheetAt(0)
0.upto(sheet.getLastRowNum()) {
  def row = sheet.getRow(it)
  def cell = row.getCell(0)
  sampler.addArgument('parameter' + it, cell.getStringCellValue())
}

就是这样,当您运行测试时,上述Groovy脚本将添加以下参数:

That should be it, when you run your test the above Groovy script will add the following parameters:

parameter1=record1
parameter2=record2
etc.

查看如何在您的JMeter测试文章中实施数据驱动测试,以在需要时进行更详细的说明.

Check out How to Implement Data Driven Testing in your JMeter Test article for more detailed explanation if needed.

这篇关于Jmeter:Excel上载,在下一个请求中传递的硬编码参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆