using variable in my execution

Hi All, so I want to use a value I grabbed by doing a “saveAs” in my execution(see below), but I keep on getting no key found for variable message.

.get(uri1 + “/directions/v2/route?key=Gmjtd|luur29u7nq,b2=o5-lr7sq&cacheBust=1430859929887,6&callback=MQA.RouteIO.CALLBACKS.c14308599298876&json={%22locations%22:[{%22latLng%22:{%22lat%22:40.9555427,%22lng%22:-74.219073}},{%22latLng%22:{%22lat%22:40.915984,%22lng%22:-73.996009}}],%22mapState%22:null,%22options%22:{%22generalize%22:0,%22shapeFormat%22:%22raw%22,%22unit%22:%22m%22}}”)
.check(regex("""“distance”:[0-9]*.?[0-9]""").transform(str => str.substring(11)).saveAs(“distance1”))
.formParam(""“distance”"", “”“distance1"”")

I have tried with no luck
.formParam(""“distance”"", “”"${distance1}""")
.formParam(""“distance”"", “”“distance1"”")



In Scala you surround your strings with three quotes so that you don’t have to worry about escaping characters or another "

Good luck.

That doesn’t work in this case, not sure why. Could it have anything to do with the way I am extracting the value using regex?

.check(regex(""""distance":[0-9]*\.?[0-9]""").transform(str => str.substring(11)).saveAs("distance1"))

so in my form parameter the value is not substituted. However, if I use the following

.exec((s:Session) => {println("*******DISTANCE = "+ s.attributes("""distance1"""));s})

this works

Enable logging in logback-test.xml and run the test again, manually check to make sure distance1 has a value. If not then your regex isn’t working. I recommend validating your regex with proper input here