Simple JavaScript scripting example - Random Number

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
I have tried to make a JS-script, but I find it difficult, ref. FAQ Question 15 (p.414) in the User's Guide.
1) Is the description of this FAQ Question updated according to version 4.5 of SOAtest? I have problems to understand the explanation.
2) Is it possible to make a small example in JavaScript (there are few examples in JS) which returns a random value for a parameter, e.g.
CODE
getItemById:
     id: 3 where the fixed parameter "3" is replaced by a random function which returns a value between 0 and 10 like CODEgetItemById:
     id: getRandom(10)
3) Is is possible to make this script global? If I have many places where random numbers are needed, I want to define the script (JS/Python/Java function) one place and call the function for each parameter.
Tagged:

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    That part of the FAQ is outdated. Here are updated directions:

    1. Select the SOAP Client.
    2. In the right GUI panel, select "Script" from the drop down menu for the input.
    3. Click on the "Edit Script" button.
    4. Enter the script in the text box or choose a file that has the script.

    You can use the standard Java API in the javascript. For instance, you can use java.util.Random for making random numbers.

    I've attached a test suite that has examples of both copy/pasting the script into the text box and using a text file. This example generates random numbers from 0-10.
Sign In or Register to comment.