Topic - Using the Gatling .replace function
Issue - Even after seeing some examples, I am still unsure of how to apply it in my script.
Goal - I am looking for some guidance beyond, “Go find a different job.”
I have a Gatling script that captures a stateToken as it accesses the site:
.exec(http("00_Access_Site_10") // This exec captures the stateToken parameter .get("https://sso-cert.johndeere.com/login/login.htm?fromURI=%2Fapp%2Fjohndeerecert_dealerpathcert_1%2Fexkcj9qb4cfudNvLR1t7%2Fsso%2Fsaml") .header("Accept:", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3") .header("Accept-Encoding:", "gzip, deflate, br") .header("Accept-Language:", "en-US,en;q=0.9") .header("Sec-Fetch-Site:", "none") .header("Sec-Fetch-Mode:", "navigate") .header("Sec-Fetch-User:", "?1") .check(regex(""""(?<=stateToken":")(.*)(?=","help)""").saveAs("StateToken")) //.check(bodyString.saveAs(key = "responseBody")) )
The stateToken value looks like this:
00_D0I**\x2D**uD5_eP91_DKeY5WBOyG1QmBI8XI07RcKR7w 00zPy2y**\x2D**gNvqQpIkscwm6xqkPIejV8PiuxHRI0tQu**\x2D** 00MmrWDdV0M_UMSTFSf**\x2D**ZaKdJnWcyx3x1fDQuTbG1r 009lfnOip9qbmZTq0qSPbi6DqTRynyEXoWpWbmt_uUcode here...
I need to replace the \x2D values in the captured stateToken with a hypen.
.replace sounds like the ticket. But how to use it?
It seems that I should add a phrase in my script to parse the captured stateToken, replacing the \2D “on the fly”.
Here is what I think I should add:
`
val str = “{StateToken}”
str.replace("\x2D","-")
`
Is this right?
How can I check that it worked?
Thanks,
Randy