This topic provides an example of how you can use keywords with parameters. A keyword or a keyword sequence can have a combined total of 20 input and output parameters.
As a first step, create a keyword-driven test which contains the keywords that you want to use. You can do this by recording an entire keyword-driven test, or by creating a new keyword-driven test and by adding the keywords in the keyword-driven test editor.
The next step is to add the parameters to the keywords. To do this, open the test scripts of the keywords and add the parameters to the methods.
// C# code [Keyword] public void Login() { ... }
' VB .NET code <Keyword> public Sub Login() ... End Subto
// C# code [Keyword] public void Login(string UserName, string Password) { ... }
' VB .NET code <Keyword> public Sub Login(UserName As String, Password As String) ... End Sub
// C# code [Keyword] public void GetCurrentUser() { ... }
' VB .NET code <Keyword> public Sub GetCurrentUser() ... End Subto
// C# code [Keyword] public void GetCurrentUser(out string CurrentUser) { ... }
' VB .NET code <Keyword> public Sub GetCurrentUser(ByRef CurrentUser As String) ... End Sub
The keyword-driven test in the
Keyword-Driven Test Editor should look similar to the following:
Now you can specify actual values for the input parameters in the
Keyword-Driven Test Editor. To retrieve the value of the output parameter
UserName of the keyword
GetCurrentUser, provide a variable, for example
${current user}. You can then pass the value that is stored in the variable to subsequent keywords.