Defining Parameters to Pass Between a Visual Test and a Script

Any parameters to be passed to and from a script must be defined as input and output parameters for the script.

  1. Open the script that you want to use to pass parameters between it and a visual test.
  2. Add the input parameters that define the parameters passed from the visual test to the script.
    1. In the Properties pane, right-click and choose Add Input Parameter.
      The Add Script Input Parameter dialog box opens.
    2. Type a name for the parameter into the Name field.
    3. Select a data type for the parameter from the Type list.

      Silk Test Workbench supports the following parameter types:

      Boolean

      The parameter's value is either True or False.

      Number (Double)

      The parameter's value is a double-precision floating-point number, and is stored as a 64-bit number in the range -1.7E308 to +1.7E-307.

      Number (Long Long)

      A 64-bit integer value that can have a value in the range -9223372036854775808 to 9223372036854775807.

      Number (Long)

      The parameter's value is a number ranging from -2,147,483,648 to 2,147,483,647. Periods (for a fractional/decimal value) cannot be used.

      Text

      The parameter's value is a text string. Text type values can contain letters, numbers, spaces, and punctuation.

    4. Leave the Default Value text box empty.
    5. Click OK.
      The input parameter displays in the list of input parameters in the Properties pane.
      Note: Input parameters defined for a script do not appear in the script itself. You can view input parameters in the Properties pane.
  3. Add the output parameters that define the parameters passed from the script to the visual test.
    1. In the Properties pane, right-click and choose Add Output Parameter.
      The Add Script Output Parameter dialog box opens.
    2. In the Name text box, type the name of the parameter that you want to pass to the visual test.
    3. Click OK.
      The output parameter displays in the list of output parameters in the Properties pane.
      Note: Output parameters do not appear in the script unless they are actually declared in the script.
    The following code sample shows how you can use the passed variables. It shows how you can modify the subroutine Main() to include the parameters that you want to create and how you can access these parameters using the dictionary. Define inputParameterName as an input parameter and outputParameterName as an output parameter.
    Public Module Main
      Dim _desktop As Desktop = Agent.Desktop
    
      Public Sub Main(args As IDictionary(Of String, Object))
        Dim text As String = args.Item("inputParameterName")
        args.Item("outputParameterName") = "someValue"
      End Sub
    End Module
  4. Open the visual test that you want to use to pass parameters between it and a script.
  5. If the script has been included in at least one visual test, to view the most up-to-date parameters in the visual test, in the Properties pane of the inserted script step, click the Name text box, and then click Refresh Parameters.
  6. Edit the value of the input parameter that you want to use in the script in the Properties pane in the visual test. When you playback the visual test, the input parameter is passed to the script.
    Note: The value that you send from the visual test is not saved in the script, but it can be used in computations in the script.

Output parameters must also be set as local variables in a visual test to pass the parameters to the visual test.