listscalagatling

Gatling how to substitute the dynamic values captured to a list


In gatling, I am extracting the list of propertyid's from the request using below check function.

            .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
            })
            

I am getting the following property id's captured to a list.

List(44772164, 44772175, 44772176, 44772177, 44772196, 44772197, 44772198, 44772212, 44772213, 44772214, 44772226, 44772227, 44772228, 44772247, 44772248, 44772249, 44772260, 44772261, 44772262, 44772276)

I will need to format and substitute these values in the below request in comma seperated format(as in request below). Depending on the address the number of propertyid will diifer..can have 1 or many, could you please guide me on how it can be done.

.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"))


Solution

  • Use transform in your check, see https://docs.gatling.io/reference/script/core/checks/#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")
      )
    )