繁体   English   中英

Gatling 如何将捕获的动态值替换为列表

[英]Gatling how to substitute the dynamic values captured to a list

在 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 捕获到列表中。

列表(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”)获得(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")
  )
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM