Setting Up the Visual Test to Use Script Data

To set up a visual test to use script data, you must insert a step that plays back the script, create a local variable to store the script data, and associate the local variable with the script output variable. Additionally, to pass data from a visual test to a script, you must set the values of the script input variables.

  1. Open the AutoQuote visual test.
  2. Choose File > Save As. The Save As dialog box opens.
  3. Since you will be modifying the AutoQuote visual test, rename it to AutoQuote_Modified to differentiate it from the original test, and then click OK.
  4. Select the step after the following step text: Playback visual test 'AddAccount'
  5. In the Test Steps pane, click Actions > Insert > .NET Script. The Browse for .NET Script dialog box opens.
  6. Select function_randomAge, and then click OK. Silk Test Workbench inserts a step that plays back the script.
  7. To add a local variable to store the script data, perform the following steps:
    1. In the Test Steps pane, click Actions > Insert > Variable > Add Local. The Add Local Variable dialog box opens.
    2. In the Variable name text box, type VTrandomAge.
    3. From the Type list, select Number (Double) and leave the Initial value set to 0.
    4. Click OK. You can see the variable and edit its definition from the <<Start>> step.
  8. Select the step for the script. The step looks like:Playback .NET Script 'function_randomAge'.
  9. In the Properties pane of the inserted script step, click in the value area of the Pass contents of 'TSrandomAge' into property and select the local variable VTrandomAge. Since we added input parameters in the script, those values display in the Properties pane. However, you can modify the input parameters used in the visual test by editing the values. These values are not changed in the script.

Your visual test is now set up to use script data. Each time the AutoQuote_Modified visual test plays back, the function_randomAge script is played back and passes a unique random number to the local variable, VTrandomAge, in the visual test.

Now, modify the step that enters the age information to use the visual test local parameter containing the random number generated in the function_randomAge script.