Gatling HTML response

415 Views Asked by At

Below is my HTML response in Gatling. I am looking to extract the value of the url field. How do I do that?

script type="text/javascript" id="test">
  var initialVars={ "context" : { "A": "XXXX", "B":"XXXXX"}, "u.d" : {"C":"ABC", "D":"FGH"}}; 
  var z = {"desktop": {"Q": "12345"}, "q.d": {"F": "QQQ", "url": "A&B=345=hhh"}}
2

There are 2 best solutions below

1
On

I'm afraid you'll have no choice but to use regular expressions here. HTML parsers such as Gatling's CSS selectors support won't be of any help as you're trying to capture some data in inlined JavaScript.

Then, your problem has nothing to do with being new to Scala or Gatling. It's about using/learning Java regular expressions.

If you struggle, you should read the Java patterns documentation and try some online evaluator.

Once you have your regex figured out, use it to add a regex check in your Gatling test.

1
On

Thank you! I figured out most of it.. This is the part that I am trying to extract transId=7a2cd0ada80a8285cd1234d144631e80&pzFromFrame Following REGEX expression ([0-9]+[a-z]+) extracts 7a2cd0ada80a8285cd1234d144631e leaving 80. How to extract 7a2cd0ada80a8285cd1234d144631e80?