You can create and pass parameters between a parent and child script or using a single script. The advantage of using a parent and child scenario is that multiple child scripts can use the parent script. For example, if the parent script creates a random number, you might want to use that functionality in several child scripts.
For example, you might name the script "NameParameters."
Public Sub Main() Dim args As New Dictionary(Of String, Object) args("FName") = "Chris" args("LName") = "Smith"
Public Module Main Dim _desktop As Desktop = Agent.Desktop Public Sub Main() Dim args As New Dictionary(Of String, Object) args("FName") = "Chris" args("LName") = "Smith" Workbench.RunScript("childscript", args) End Sub End Module
MsgBox("Hello, " + args("FName") + "!") MsgBox ("Hello, " + args("FName") + " " + args("LName") + "!")A message box opens when the script plays back and shows the values that the test enters.
Imports SilkTest.Ntf.XBrowser Public Module Main Dim _desktop As Desktop = Agent.Desktop Public Sub Main() With _desktop.BrowserWindow("/BrowserApplication[1]//BrowserWindow") .DomButton("@id='login-form:signup'").Select() .DomTextField("@id='signup:fname'").SetText("first") .DomTextField("@id='signup:lname'").SetText("last") .DomElement("@src='http://extjs.com/s.gif'").DomClick(MouseButton.Left, New Point(8, 16)) .DomButton("@textContents='Today'").Select() .DomTextField("@id='signup:email'").SetText("test@test1.com") .DomTextField("@id='signup:street'").SetText("123 street rd") .DomTextField("@id='signup:city'").SetText("Marlton") .DomListBox("@id='signup:state'").Select("Massachusetts") .DomTextField("@id='signup:zip'").SetText("09876") .DomTextField("@id='signup:password'").SetText("test") .DomButton("@id='signup:signup'").Select() .DomButton("@id='signup:continue'").Select() End With End Sub End Module
Public Sub Main(args As IDictionary(Of String, Object))
.DomTextField("@id='signup:fname'").SetText("first") .DomTextField("@id='signup:lname'").SetText("last")
.DomTextField("@id='signup:fname'").SetText(args("FName")) .DomTextField("@id='signup:lname'").SetText(args("LName"))