Answered question

How to use a value captured in a JavaScript?

I have a result of a function in a NeoLoad variable inside my Javascript:

context.variableManager.setValue("body", body);

How can I use this variable in a Method: Post and Content Type: text ?

I tried with ${body} in the Text Content but it does not work.

Thanks

Begona P.
Begona P.

Begona P.

Level
0
21 / 100
points

Did you find this useful ?

No (0)

Yes (0)

0% of users found this answer useful

Other answers

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

It is the right way to use your variable. When you say it does not work do you mean that the variable is not replaced while replaying your request?

Could you provide some screen shots describing that behavior?

Begona P.
Begona P.

Begona P.

Level
0
21 / 100
points

As you can see, I execute de JS named "JavaScriptGeneratingBody", (attached the code in the below image). The response generates 400 error.
What I want is generate 10 random json. The variables "randomAccountNumber", "randomBalance"... work perfectly. The problem is when I try to capture the variable "body".
Thanks

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

I'm not a JS specialist but if i use your code without the evaluate function it works fine. I can't tell why it does not work inside your evaluate function.

Begona P.
Begona P.

Begona P.

Level
0
21 / 100
points

This is the solution, deleting the the line of the evaluate function works fine.
Thanks a lot!