How do I pass parameters in a Silk Test Workbench dotNet script?
A Silk Test Workbench expects the Main() call to have no parameters. Any attempt to add parameters will result in the playback error:-
However, Main() is overloaded and can be called from itself. For this example, first you will need to define two input parameters in the Properties tab:
The following script will take the arguments dictionary and will pass it to the overloaded version of Main(args):-
Public Module Main
Dim _desktop As Desktop = Agent.Desktop
Public Sub Main()
Dim args = New IDictionary(Of String, Object)
args("myParam") = "test value"
args("myParam2") = "another test value"
Public Sub Main(args)
Dim myArg1 As String = Nothing
Dim myArg2 As String = Nothing
On the face of it, it doesn't look right in that there are two Main() calls. However, the second one has an overload (args), so Silk Test will ignore it in favour of the first, non-overloaded version. The first Main() then calls the overloaded Main(args) and passes across the key-pair contents of the Dictionary. Whatever you have defined as the contents of the argument string(s) in the first Main() call is what will be passed to the overloaded version. Although we have hard-coded them here, there is nothing to stop you reading data from an ActiveData source or a text file before passing the information to the overloaded Main() call.