Help need for parsing a session token which is provided as part of query params in response

69 views
Skip to first unread message

Vivek Sadhineni

unread,
Mar 23, 2017, 1:27:23 AM3/23/17
to Gatling User Group
Hi Team, 

I am newbie to Gatling and I am struggling to parse the session returned for my http post request.I am using New Gatling version 2.2.4

Please find my request and response and suggest me how to extract the session token value and parse it other requests.

Request:
val customerlogin = exec(http("customerlogin")
.post("/user/customerlogin?deviceName=iphone&deviceType=phone&modelNo=6s&serialNo=12345678&lang=en_US")
.formParam("operator", "HBO-GO")
.formParam("email", "${userName}")
.formParam("password", "password1")
.formParam("returnURL", "/user/success")
.formParam("deviceName", "iphone")
.formParam("deviceType", "phone")
.formParam("modelNo", "6s")
.formParam("serialNo", "12345678")
.get("/user/success?sessionToken").saveAs(sessionToken)
)
Response :

HTTP response:
status=
302 Found
headers=
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Content-Type: text/html; charset=UTF-8
Date: Thu, 23 Mar 2017 03:36:51 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Location: /user/success?sessionToken=VC6d-uayB-Kes3-os6M-YuDo-0SSj-DK&channelPartnerID=HBO_Asia&lang=en_US
Pragma: no-cache
Server: Apache/2.4.25 (Amazon) PHP/5.6.29
Set-Cookie: PHPSESSID=0bgu3oktlia2vtg5r9kv0jigj2; path=/
Set-Cookie: locale=en_US
X-Powered-By: PHP/5.6.29
Content-Length: 0
Connection: keep-alive

I want the value in the sessionToken to be parsed to another request. Need your help to get knowledge on how to deal with this problem.

Thanks in Advance
Vivek
Message has been deleted

emre.y...@wittycommerce.com

unread,
Mar 27, 2017, 10:30:12 AM3/27/17
to Gatling User Group
Hello, 

My solution to this case is something like this:

var sessionToken :String = ""

val customerlogin = exec(http("customerlogin")
.post("/user/customerlogin?deviceName=iphone&deviceType=phone&modelNo=6s&serialNo=12345678&lang=en_US")
.formParam("operator", "HBO-GO")
.formParam("email", "${userName}")
.formParam("password", "password1")
.formParam("returnURL", "/user/success")
.formParam("deviceName", "iphone")
.formParam("deviceType", "phone")
.formParam("modelNo", "6s")
.formParam("serialNo", "12345678")
.exec(session => {      
sessionToken= session.get("sessionToken").as[String]
session
 })
                        .exec(http("nextRequest")
.post(session => "/someurl" + sessionToken + "/voyages"))

Vivek Sadhineni

unread,
Mar 27, 2017, 10:37:40 AM3/27/17
to gat...@googlegroups.com
Hi Emre Yildirim,

Thanks for the help , currently we have hard coded the url to get the session with currentLocationRegex

currentLocationRegex("https://www.website.com/user/success?(.*)=(.*)").ofType[(String,String)]

I will check with the Session and update my result.


Thanks & Regards ,
Vivek S,

Evergent Technologies India limited.

--
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/USTEfkeO1fY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gatling+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages