Using Parameters with Keywords

A keyword or a keyword sequence can have a combined total of 20 input and output parameters. This topic describes how you can handle these parameters with Silk Test Workbench, when you are working with keywords that are implemented as VB .NET scripts.

In the Keyword-Driven Test Editor, you can view any defined parameters for a keyword or a keyword sequence and you can edit the parameter values.

In the Keywords window, you can see which parameters are assigned to a keyword or a keyword sequence when you hover the mouse cursor over the keyword or keyword sequence.

Note: For keywords that are implemented as visual tests, you can specify input and output parameters in the Input parameters and Output parameters sections in the Properties window of the <<Start>> step.

Input parameters for simple keywords

You can define and use input parameters for keywords that are implemented as VB .NET scripts in the same way as for any other test method.

The following code sample shows how you can define the keyword SetUserDetails with the two input parameters userName and password:
' VB .NET code
<Keyword>
public Sub SetUserDetails(userName As String, password As String)
  ...
End Sub

Output parameters for simple keywords

You can define a return value or one or more output parameters for a keyword that is implemented as a VB .NET script. You can also use a combination of a return value and one ore more output parameters.

The following code sample shows how you can define the keyword GetText that returns a string:
' VB .NET code
<Keyword>
public Function GetText As String
  Return "text"
End Function
The following code sample shows how you can define the keyword GetUserDetails with the two output parameters userName and password:
' VB .NET code
<Keyword>
public Sub GetUserDetails(ByRef userName As String, ByRef password As String)
  userName="name"
  password="password"
End Sub

Parameters for keyword sequences

You can define or edit the parameters for a keyword sequence in the Parameters dialog box, which you can open if you click Parameters in the Keyword Sequence Editor.