Hi,
- How to extract an value from HTML
a href="/apps/…do?actionType=adminPage&authtoken=d8f8f981-f7a9-4ba1-9cd9-03e9b60a91cb" onClick = "javascript:
how to extract authtoken value from the above one.
2 . how to extract from jsonResponse want to store in each item in variable
({“data”:"1, 2, 3}),
Thanks in Advance
Gatling http checks page has all the solutions. http://gatling.io/docs/2.1.7/http/http_check.html
-
if you want to extract from string then use Regex. If you want the the whole href, you can also use CSS (link).
-
For Json, search for jsonPath on this page.
Hi,
I tried with both regex and css but i am not able to get the value of authtoken (refered above)
1 .check (regex("""“authtoken”="([^"]*)""").saveAs(“AuthToken”))
2. .check (css(“href=”/apps/…do?actionType=adminPage", “authtoken”).saveAs(“AuthToken”))
with css i am getting the below error
,UTF-8),Map(),2285,UTF-8,RequestTimings(1440478289443,1440478289445,1440478289976,1440478289976)))), forwarding user to the next action
jodd.csselly.CSSellyException: Invalid combinator <=>. (state: 6)
at jodd.csselly.CSSellyLexer.yylex(CSSellyLexer.java:776) ~[jodd-lagarto-3.6.5.jar:3.6.5]
at jodd.csselly.CSSelly.parse(CSSelly.java:38) ~[jodd-lagarto-3.6.5.jar:3.6.5]
at jodd.csselly.CSSelly.parse(CSSelly.java:73) ~[jodd-lagarto-3.6.5.jar:3.6.5]
using Gatling 2.2 version
Try following
1
.check (regex("""authtoken=([^"]*)""").saveAs("Authtoken") //- https://regex101.com/
2 for CSS parser I will need entire html. You can use the following site to test out CSS parser http://try.jsoup.org/
- Can you help to get value from json Response using json parser
My Json String =({“data”:"1, 2, 3})
Sure
check(jsonPath($.[data]).saveAs("myData"))
You can use this link to test your json parser yourself https://jsonpath.curiousconcept.com/ - Select Stefan Goessner implementation
Quick tutorial on jsonPath syntax - http://goessner.net/articles/JsonPath/
Hi Abhinav,
Thanks again.
i used jsonPath("$")previously so i didn’t get what i am expected,**Thanks it is also working fine with jsonPath("$.data")…**