Answered question

How to use XPath or JSONPath on Javascript action in Neoload?

Hello All

I am looking on the documentation on Neoload, but I couldn't find any example that shows how to use XPath or JSPNPath on a Javascript action as custom code. I am passing a variable which contains a JSON message. I just want to extract some values from there. I tried with regex but the JSON make it complicated due the format.

Thank you in advance!

Ageo D.
Ageo D.

Ageo D.

Level
0
14 / 100
points
christophe M.
christophe M.

christophe M.

Level
4
5000 / 5000
points
Team

You can use W3C Functions (https://www.w3schools.com/js/js_json_intro.asp)

An example that works in NeoLoad JavaScript action:

var obj = JSON.parse('{ "name":"John", "age":30, "city":"New York"}');

logger.debug("Name="+obj.name);

Did you find this useful ?

No (0)

Yes (2)

100%

100% of users found this answer useful