# How to add dynamic params?

**URL:** <https://community.gatling.io/t/how-to-add-dynamic-params/1111>\
**Category:** Gatling (Open-Source)\
**Created:** [June 25, 2014, 3:21am UTC](https://community.gatling.io/t/how-to-add-dynamic-params/1111 "2014-06-25T03:21:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ictest0214](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ictest0214](https://community.gatling.io/u/ictest0214)\
**Post date:** [June 25, 2014, 3:21am UTC](https://community.gatling.io/t/how-to-add-dynamic-params/1111/1 "2014-06-25T03:21:15Z")

</div>

Hi,

I have multiple hidden fields that are generated automatically:

And i use regex to collect values:  
.check(regex(""“hdnUser” value="([\w=/.\d\_%±.]\*)"""").findAll.saveAs(“hdnUser”))

I can access “hdnUser” session to get values:  
.exec(session =\> {  
var users = session(“hdnUser”).as[Seq[String]]  
users.foreach(user =\> {  
println(user)  
})  
session  
})

Now, I’d like to add them to params dynamically in next post as below, how can i achieve this by using session(“hdnUser”) above?  
.exec(http(“request\_13”)  
.post("""/Activate.aspx""")  
.param(""“ctl00$PlaceHolderMain$dtlUsers$ctl00$hdnUser”"", “”“pa0"”")  
.param(""“ctl00$PlaceHolderMain$dtlUsers$ctl01$hdnUser”"", “”“pa1"”")  
.param(""“ctl00$PlaceHolderMain$dtlUsers$ctl02$hdnUser”"", “”“pa2"”")  
.param(""“ctl00$PlaceHolderMain$dtlUsers$ctl03$hdnUser”"", “”“pa3"”")

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 25, 2014, 9:36am UTC](https://community.gatling.io/t/how-to-add-dynamic-params/1111/2 "2014-06-25T09:36:52Z")

</div>

Is it expected that input names and param names differ ($ instead of \_)?

ctl00\_PlaceHolderMain\_dtlUsers\_ctl00\_hdnUser vs ctl00$PlaceHolderMain$dtlUsers$ctl00$hdnUser

---

<div class="post-metadata">

**Author:** ![ictest0214](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ictest0214](https://community.gatling.io/u/ictest0214)\
**Post date:** [June 26, 2014, 3:18am UTC](https://community.gatling.io/t/how-to-add-dynamic-params/1111/3 "2014-06-26T03:18:21Z")

</div>

I’m using [asp.net](http://asp.net) and server generate id with “\_” and name with “$”. When post to server, it just recognize “$” so we must use “ctl00$PlaceHolderMain$dtlUsers$ctl00$hdnUser” for param in post.  
I was able to achieve this by:  
.paramsSeq(session=\>{  
var users = session(“hdnUser”).as[Seq[String]]  
var b = Seq((“b”,“5”),(“c”,“4”))  
var i = 0;  
users.foreach(user =\> {  
var name = “ctl00$PlaceHolderMain$dtlUsers$ctl0”+ i.toString +"$hdnUser"  
b = b :+ (name, user.name)  
i = i + 1;  
})  
b  
})

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 26, 2014, 5:40am UTC](https://community.gatling.io/t/how-to-add-dynamic-params/1111/4 "2014-06-26T05:40:04Z")

</div>

Oups, sorry.

A proper solution with upcoming version is to use a regex with 2 capture groups (one for name and one for value):  
[https://github.com/excilys/gatling/blob/master/src/sphinx/http/http\_check.rst#http-response-body](https://github.com/excilys/gatling/blob/master/src/sphinx/http/http_check.rst#http-response-body)

```auto
regex("foo(.*)bar(.*)baz").ofType[(String, String)]

```

and then directly post the pairs:

- `paramsSeq(seq: Expression[Seq[(String, Any)]])`

---

<div class="post-metadata">

**Author:** ![ictest0214](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ictest0214](https://community.gatling.io/u/ictest0214)\
**Post date:** [June 26, 2014, 7:16am UTC](https://community.gatling.io/t/how-to-add-dynamic-params/1111/5 "2014-06-26T07:16:54Z")

</div>

Sorry,

regex(""“hdnUser” value="([\w=/.\d\_%±.]\*)"""")…ofType[(String, String)]

throw error:  
value ofType is not a member of io.gatling.http.check.HttpMultipleCheckBuilder[CharSequence,String]  
regex(""“hdnGroupLevel” value="([\w=/.\d\_%±.$]\*)"""").ofType[(String, String)],  
^

i’m using Gatling 2.0.0-SNAPSHOT.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 26, 2014, 7:43am UTC](https://community.gatling.io/t/how-to-add-dynamic-params/1111/6 "2014-06-26T07:43:11Z")

</div>

You use an old snapshot. HttpMultipleCheckBuilder doesn’t even exist anymore.

---

<div class="post-metadata">

**Author:** ![ictest0214](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@ictest0214](https://community.gatling.io/u/ictest0214)\
**Post date:** [June 26, 2014, 7:52am UTC](https://community.gatling.io/t/how-to-add-dynamic-params/1111/7 "2014-06-26T07:52:57Z")

</div>

I’m get Gatling from Maven:  
  
  
sonatype  
Sonatype OSS  
[https://oss.sonatype.org/content/groups/public](https://oss.sonatype.org/content/groups/public)  
  
true  
  
  
  
  
\<maven.compiler.source\>1.7\</maven.compiler.source\>  
\<maven.compiler.target\>1.6\</maven.compiler.target\>  
\<scala.version\>2.10.4\</scala.version\>  
UTF-8

\<gatling.version\>2.0.0-SNAPSHOT\</gatling.version\>  
\<gatling-highcharts.version\>2.0.0-SNAPSHOT\</gatling-highcharts.version\>

\<scala-maven-plugin.version\>3.1.6\</scala-maven-plugin.version\>

Where can i get latest?

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 26, 2014, 7:54am UTC](https://community.gatling.io/t/how-to-add-dynamic-params/1111/8 "2014-06-26T07:54:52Z")

</div>

see [https://github.com/excilys/gatling/issues/1821](https://github.com/excilys/gatling/issues/1821)
