How to extract different dynamic values from the response of single request using multiple check and saveas and use them in another request??

345 views
Skip to first unread message

Alok Dagar

unread,
Jan 24, 2017, 3:21:59 PM1/24/17
to Gatling User Group
Below is the base request whose upon redirection is supposed to carry the response that I need to use in another request
I am trying like this
val httpProtocol = http
.baseURL("https://www.testciq.com").check(regex("""<input type=\"hidden\" name=\"__VIEWSTATEGENERATOR\" id=\"__VIEWSTATEGENERATOR\" value=\"(.*)/>""").saveAs("VIEWSTATEGENERATOR"),regex("""<input type=\"hidden\" name=\"__EVENTVALIDATION\" id=\"__EVENTVALIDATION\" value=\"(.*)/>""").saveAs("EVENTVALIDATION"),regex("""<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=\"(.*)/>\"""").saveAs("VIEWSTATE"))
.inferHtmlResources(BlackList(""".*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.(t|o)tf""", """.*\.png"""), WhiteList())
.acceptHeader("*/*")
.acceptEncodingHeader("gzip, deflate, br")
.acceptLanguageHeader("en-US,en;q=0.5")
.connection("keep-alive")
.contentTypeHeader("application/x-www-form-urlencoded")
.userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0")

and using the saved values in another request like below:
http("MainLogin")
.post("https:// sso.beta.mhfi.com:443/oam/server/auth_cred_submit")
.headers(headers_0)
.formParam("__EVENTTARGET", "")
.formParam("__EVENTARGUMENT", "")
.formParam("__VIEWSTATE", "${VIEWSTATE}")
.formParam("__VIEWSTATEGENERATOR","${VIEWSTATEGENERATOR}")
.formParam("__EVENTVALIDATION", "${EVENTVALIDATION}")
.formParam("captchaValidated", "0")


But this is not working... Any help would be greatly appreciated...Thanks


Stephen

unread,
Jan 25, 2017, 3:40:46 AM1/25/17
to Gatling User Group
Hello,

Did you check the values you obtained for ${VIEWSTATE}, ${VIEWSTATEGENERATOR} and ${EVENTVALIDATION} ? What response are you getting ?

Alok Dagar

unread,
Jan 25, 2017, 8:08:35 AM1/25/17
to Gatling User Group
since I am new to gatling don't know... how can I get them checked

Nikolay Degkin

unread,
Jan 25, 2017, 8:51:42 AM1/25/17
to Gatling User Group
Try to print it
.exec { session =>
println(session("VIEWSTATE").as[String])
session 
}

Alok Dagar

unread,
Jan 25, 2017, 4:24:42 PM1/25/17
to Gatling User Group
Hi... Nikolay and Stephen... Thanks for replying... I have been able to solve the issue by changing the regular expressions.... But now stuck with cookie management since gatling is not handling all the cookies because of which some requests are failing

Stephen

unread,
Jan 26, 2017, 3:14:12 AM1/26/17
to Gatling User Group
Maybe you can create the cookie by yourself using addCookie : http://gatling.io/docs/2.2.3/http/http_helpers.html?highlight=cookie
Reply all
Reply to author
Forward
0 new messages