list - Gatling 如何将捕获的动态值替换为列表
问题描述
在 gatling 中,我使用以下检查功能从请求中提取 propertyid 列表。
.get(uri21 + "/search/address/q=20+ABC+Street&qt=address&view=property&newSearch=true&searchWindowId=")
.check(regex("""propertyKey="(.*?)"""").findAll.saveAs("propertyid")))
.exec(session => {
println(session("propertyid").as[String])
session
})
我将以下属性 ID 捕获到列表中。
List(44772164, 44772175, 44772176, 44772177, 44772196, 44772197, 44772198, 44772212, 44772213, 44772214, 44772226, 44772227, 44772228, 44772247, 44772248, 44772249, 44772260, 44772261, 44772262, 44772276)
我需要在以下请求中以逗号分隔格式格式化和替换这些值(如下面的请求)。根据地址的不同,propertyid 的数量将不同..可以有 1 个或多个,请您指导我如何完成。
.exec(http("/torchlist") .get(uri21 + "/torchlist/status.json?property_id=44772164, 44772175, 44772176, 44772177, 44772196, 44772197, 44772198, 44772212, 44772213, 44772214, 44772226, 44772227, 44772228 , 44772247, 44772248, 44772249, 44772260, 44772261, 44772262, 44772276&_=1627273897640&search_type_param=address"))
解决方案
transform
在您的支票中使用,请参阅https://gatling.io/docs/gatling/reference/current/http/check/#transforming
.get(uri21 + "/search/address/q=20+ABC+Street&qt=address&view=property&newSearch=true&searchWindowId=")
.check(
regex("""propertyKey="(.*?)"""")
.findAll
.transform(listOfIds => listOfIds.mkString(","))
.saveAs("concatenatedIds")
)
)
推荐阅读
- c++ - ncurses中的“红心❤️”Unicode字符
- go - net/http 和 ant 每次运行都会给我不同的结果
- powershell - 在 Powershell 中使用 Invoke-SSHCommand 传递变量
- python - Pandas - 附加包含不完整列的 CSV 文件
- templates - jinja 模板删除空格
- java - 两个同时请求导致 401(cookie JSESSIONID?)
- java - 从 Maven 配置中设置 VM 选项
- python - 如何计算另一组的平均值?
- json - 从“获取”到“显示”JSON API 数据的转变 Swift Node.js
- .net - 使用 Azure App Config -> 希望允许本地配置覆盖开发人员