Unanswered question

CSRF value stored in a variable in JS and to be extracted

CSRF value is computed and stored in a variable in a
response of JS File. This value is available in a variable with in a function. I would need to copy this value in to a variable of my java script, which then could be used for other request.

Please let me know the way with which we could do it.

Varun P.
Varun P.

Varun P.

Level
0
3 / 100
points

Answers

Chirapapan P.
Chirapapan P.

Chirapapan P.

Level
0
87 / 100
points

@Neil.W Im working with a cryptojs and I have to get a value from reponse to pass in as a parameter to hash a hmac key. How can I get a extracted variable in Javascript? I have tried getValue but the extracted variable is not store in Variable Manager. And I cannot use ${} form in javascript

Looking forward to hearing from you

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

getValue is the way to get the content of any NeoLoad variable content. It does not matter if you have created it in Variable manager or anywhere in NeoLoad. What matters is that this variable exists.

I guess you have made a mistake somewhere. Could you provide more details?

Hi, it sounds like you still need to get the value from the response, to do this you need to create a variable extractor, details can be found in the help here (https://www.neotys.com/documents/doc/neoload/latest/#953.htm#o954) but basically you define the left boundary and the right boundary and Neoload will extract what's in between. As Nouredine states, once you have created the variable extractor, it can be treated like any other variable and accessed in the JS using the getValue method

Chirapapan P.
Chirapapan P.

Chirapapan P.

Level
0
87 / 100
points

I defined the extractor on one of the responses that store under my WebSocket channel. However, The validation fails because "No match found for expression" error. But if you look at my first attached image you will see that the extractor tries to extract the value from my request which will not have the response I am looking for sure, But you can see the log on the second line that it does find the expected value. However, the validation stops because of the fail. How do I specify that the extractor should only look at the second request/response to prevent the script to fail?

Chirapapan P.
Chirapapan P.

Chirapapan P.

Level
0
87 / 100
points

Nevermind, it works now. I just need to uncheck Throw an assertion error.

Extractors only work on responses. By unchecking the throw assertion checkbox you are just saying if you can't find it don't tell me. You need to figure out why it can't find it