To create new keywords for the .NET agent with Visual Studio Solution, you must first create a new Console Application project in Visual Studio:
You will then be able to choose between the latest .NET 5.0 framework or the legacy 4.x version (please note that only the latest 4.x version of the framework is tested before the release). The selected version must correspond to the .NET agent distribution that you’re using.
You will need to add the step dependencies in your projects. The following actions will have to be performed on your new Visual Studio Solution:
Deployment of your keyword library and dependencies can be done by dropping the file(s) into the gui:
The “dependencies libraries” field allows you to add the additional dlls needed by you keyword. It can be a single DLL file or a zip file containing the multiple DLLs
You can add the .pdb of your keyword DLL in the “dependencies libraries” field, by putting it directly in the filed or by adding it to the zip file
You can unit test your new keywords using the NUnit package. This will save you time as you will be able to debug your keywords without having to build and deploy your DLL to the controller.
To do that, you will first have to install the NUnit nugget dependencies (as described in this section). This will allow you to use [Test] annotated functions.
In order to have the most realistic test, you should use the ScriptRunner object which will simulate the execution of your keywords like step does. See the following example for more information.
The following .NET class is a simple example of two keywords using the Selenium driver. This demonstrate the usage of the basic API functions:
First, the new keywords are defined using the [Keyword] annotation
The getDriver and initDriver functions show the usage of a session. session.get and session.get allows to pass .NET objects during the live cycle of your virtual user. The Webdriver is typical of the usage of the session, as this driver contains the state of the user and have to be unique per virtual user. Note that we are using a wrapper class for the Driver so that the browser will be properly closed
The gotoGoogle function shows how to pass input values from the test plan to your keywords using input.GetValue
The testKeywords functions shows how to unit test your keywords using the ScriptRunner object