session variable as formParam

98 views
Skip to first unread message

lukas lang

unread,
Sep 28, 2015, 9:02:08 AM9/28/15
to Gatling User Group
Hi, i have a question about how to use session variable, as formParam.

i have string variable like this:
Questions[0].AnswerViewModel.Answers[0].QuestionAnswerId=59115&Questions[0].AnswerViewModel.Answers[1].QuestionAnswerId=59116&Questions[0].AnswerViewModel.Answers[0].IsAnswered=false&Questions[0].AnswerViewModel.Answers[1].IsAnswered=true

which is created in requests before and has variable number of "Answers[i]" ( Answers[0],Answers[1],...).


Well my question is, how can i use this string in formParam?


from session log:
FORM_PARAM_Z_FUNKCIE -> Questions[0].AnswerViewModel.Answers[0].QuestionAnswerId=59115&Questions[0].AnswerViewModel.Answers[1].QuestionAnswerId=59116&Questions[0].AnswerViewModel.Answers[0].IsAnswered=false&Questions[0].AnswerViewModel.Answers[1].IsAnswered=true

and i want to use something like:
.formParam("${FORM_PARAM_Z_FUNKCIE}").

is there any way to parse this string into .post param?

I am using gatling version 2.1.7

Thanks for any reply. :)

Lukas

Abhinav Gogna

unread,
Sep 28, 2015, 10:48:43 PM9/28/15
to Gatling User Group

lukas lang

unread,
Sep 29, 2015, 3:26:27 AM9/29/15
to Gatling User Group
I was trying it before, but with no luck.
Today i tried again, and find out, it wasnt working before, because i used both .formParam() and also .body(StringBody).
So i used only .body and it worked!

Thanks for idea :)

Lukas

Dňa utorok, 29. septembra 2015 4:48:43 UTC+2 Abhinav Gogna napísal(-a):
Message has been deleted

Manohari

unread,
Jul 26, 2016, 5:25:00 AM7/26/16
to Gatling User Group
Can you please send the sample code how the above one  works, iam facing the same issue,It will be helpful if send the code

lukas lang

unread,
Jul 26, 2016, 5:55:32 AM7/26/16
to Gatling User Group
Hi, i just didnt use .formParam at all. Use .body(StringBody) for example:
.post("/login")
.formParam("login","user1")
.formParam("id","12345")

is same as:
.post("/login")
.body(StringBody("login=user1&id=12345"))
and this way worked for me, even when i used session variable.

As mentioned before by Abjinav, also check documentation http://gatling.io/docs/2.1.7/http/http_request.html?highlight=stringbody#request-body
– skryť citovaný text –


Dňa utorok, 26. júla 2016 11:25:00 UTC+2 Manohari napísal(-a):

Manohari Srinivasan

unread,
Jul 26, 2016, 7:15:42 AM7/26/16
to gat...@googlegroups.com
Thanks for the reply Lukas, i tried the same and no luck for me.....

Thanks

Thanks
Manohari S



--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/fPmU57QiOZU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages