• Documentation
  • Tutorials
  • Case studies
  • White papers
  • Product

What's on this Page

  • .NET Plugin Installation
    • Installation
  • Keyword Project
    • .NET Solution
    • Dependencies
  • Deployment
    • Keyword Package approach
    • Manual registration approach
  • Recommended practices
    • NUnit
    • Example
  • Other API Functionality
    • Output and Attachments
  • step
  • Plugins
  • .NET agent
Categories: PLUGINS AGENTS ENTERPRISE
This article references one of our previous releases, click here to go to our latest version instead.

.NET agent

.NET Plugin Installation

Installation

Follow this link to install the .NET step Agent : .NET Agent installation

Keyword Project

.NET Solution

To create new keywords for the .NET agent with Visual Studio Solution, you must first create a new Console Application project in Visual Studio:

.Net project configuration

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.

.Net project configuration

Dependencies

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:

  • You will first have to add our enterprise nuget repository: https://nexus-enterprise.exense.ch/repository/exense-nuget/ (The user/password for accessing these artifacts will be provided to you with your enterprise license)
NuGet configuration

Three components will be available: StepApiKeyword, StepApiFunction and StepApiReporting, containing the core API and a local runner for unit testing your keywords

Deployment

Keyword Package approach

Keyword Packages allow managing Keywords in a batch way. They are the most efficient and practical way to manage Keywords at industrial scale. Please refer to the general keyword documentation.

Note: we are using an external process to discover the keywords contained in a package (DLL), the path to the correct executable must be specified in the step.properties of the controller:

  • function_discoverer-5-win64 (default) - for a controller running on windows and packages based on .NET 5.0 framework
  • function_discoverer-5-linux64 - for a controller running on Linux and packages based on .NET 5.0 framework
  • function_discoverer-5-osx64 - for a controller running on osx and packages based on .NET 5.0 framework
  • function_discoverer-4 - legacy version for packages based on .NET 4.x framework (windows only)

Example: plugins.dotnet.discoverer.path=../ext/function_discoverer-5-win64/FunctionDiscoverer.exe

Manual registration approach

Deployment of your keyword library and dependencies can be done by dropping the file(s) into the gui:

AutoIt Keyword configuration

Note that:

  • 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

Recommended practices

NUnit

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.

Example

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

    using System;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using StepApi;
    using NUnit.Framework;
    using ScriptDev;
    
    namespace STEP
    {
    public class DriverWrapper : Closeable
    {
        private IWebDriver driver;
        public DriverWrapper(IWebDriver driver) => this.driver = driver;
        public void close() => this.driver.Close();
        public IWebDriver getDriver() => this.driver;
    }
    
    public class TestSeleniumNet : AbstractScript
    {
        protected IWebDriver getDriver()
        {
            return ((DriverWrapper)session.get("chromedriver")).getDriver();
        }
        [Keyword]
        public void initDriver()
        {
            ChromeOptions options = new ChromeOptions();
            string[] optionsList = { "start-maximized", "headless" };
            options.AddArguments(optionsList);
            IWebDriver driver = new ChromeDriver(@"C:\Step\installers\", options, TimeSpan.FromSeconds(30));
            session.put("chromedriver", driver);
        }
        [Keyword]
        public void gotoGoogle()
        {
            IWebDriver driver = getDriver();
            driver.Navigate().GoToUrl("https://google.ch/search?q=" + input.GetValue("search"));
        }
        [Test]
        public void testKeywords()
        {
            ScriptRunner runner = new ScriptRunner(typeof(TestSeleniumNet).Assembly);
            runner.run("initDriver");
            runner.run("gotoGoogle", "{'search':'exense'}");
        }
    }
    }

Other API Functionality

Output and Attachments

In order to pass you data into Keywords output as JSON payload or attachment, you can use following code as an example :

Here the keyword class where we add to the output :

  • some text via the key / value pair with key “myOutputContent”
  • some text that will be available into the attachment file called “myAttachmentContent.txt”

    class KW000_SandboxKeyword : AbstractScript
    {
    [Keyword]
    public void KW000_SandboxKeywordMethod()
    {
        output.add("myOutputContent", "Here the output content");
        output.addAttachment(AttachmentBuilder.generateAttachmentFromByteArray(System.Text.Encoding.Unicode.GetBytes("[attachmentContent1, attachmentContent2, attachmentContent3"), "myAttachmentContent.txt"));
    }
    }

In order to retrieve the output information from your development environment, you can use the following code to call the keyword and display the output :

public void TestKW000()
{
    ScriptRunner runner = new ScriptRunner(typeof(KW000_SandboxKeyword).Assembly);
    OutputMessage output = runner.run("KW000_SandboxKeywordMethod");
    Console.WriteLine(output.payload.ToString());
    Console.WriteLine(System.Text.Encoding.Unicode.GetString(AttachmentBuilder.Base64Decode(output.attachments[0].hexContent)));
}

Once you execute this method, the output will be displayed as :

1519813116183-648.png

Then once you execute your Keyword within step, it will display the output message and an attachment file that you can download by clicking on the attachment icon :

1519814702037-590.png

See Also

  • Node.js agent
  • PDF and Image compare
  • cypress Plugin
  • JMeter
  • SoapUI
  • Getting Started
    • Overview
    • Quick setup (install)
    • Quick setup (SaaS)
    • My first Execution
    • Browser automation
    • Real-world scenario
    • Scaling out
  • Whats new?
    • Release notes
    • Roadmap
    • Weekly news
  • Admin guide
    • Database installation
    • Controller installation
    • Agent installation
    • Requirements
    • Backup & Restore
    • Housekeeping
    • Migration
    • Customization
    • Project management
    • Admin Views
    • Troubleshooting
    • Encryption Manager
  • User guide
    • Keywords
    • Plans
    • Executions
    • Notifications
    • Parameters
    • Dashboards
    • Monitoring
    • Scheduler
    • User Preferences
    • Event Broker Monitor
    • Executable bundles
    • Import/Export entities
  • Developer guide
    • Dev Overview
    • Keyword API
    • Measurement API
    • step client API
    • Event Broker API
  • Plugins
    • .NET agent
    • cypress Plugin
    • Node.js agent
    • ALM
    • Azure DevOps
    • Async packages
    • JMeter
    • SoapUI
    • PDF and Image compare
    • Artifact repository connector
    • Analytics and external DBs
  • Resources
    • Tutorials
    • Case Studies
    • White papers
    • Libraries
Step Logo
    • Documentation
    • Tutorials
    • Case studies
    • White papers
    • Product
    • Getting Started
    • Whats new?
    • Admin guide
    • User guide
    • Developer guide
    • Plugins
    • Resources