Dependencies will be needed for using the step API in your projects. The following actions will have to be performed on your new Visual Studio Solution:
First, the following nugget packages must be added to your new Project/Solution:
Selenium.Supportversion 3.3.0 (if creating Selenium based keywords)
Selenium.WebDriverversion 3.3.0 (if creating Selenium based keywords)
If the following error message is displayed for one of those libraries, the included version is probably incorrect:
System.IO.FileLoadException: Could not load file or assembly ‘…, Version=X.Y.Z,…’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference.
In addition, the following DLL files from step are needed for building your new keywords library:
Do an “Add reference”:
Browse for the DLLs:
Select the files ScriptDev.dll,StepApi.dll and Newtonsoft.Json.dll located in the …\Agent\bin\ folder of the Agent. You must now have two new references:
If you have additional dependencies, you can add them in the same way.
Deployment of your keyword library can be done by dropping the DLL file into the controller file system (using the same path specified during the Keyword creation (C:\Users\Administrator\source\repos\TestSelenium\TestSelenium\bin in our example). The DLL will then be uploaded on the Agents when running the keywords.
If your keyword library need additional dependencies (like the Selenium driver DLL), the following additional steps will have to be done:
Copy your additional DLLs to the …\agent\bin\ folder of the Agent
Restart the Agent
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