The following section describes how to create a test case with an action component that will execute an existing Selenium script.

  • Create an empty test case with any name

  • In the Components section, click Create a Selenium component (a) button to bring up the Create Selenium Component dialog
  • Enter a component name in the textbox (b). The name must start with a letter and can only have alphanumeric characters.
  • Select a programming language for the component (c). c# and VB.NET are supported.
  • Select a client platform to execute the selenium script (d). The options are Chrome or Firefox. It is suggested to use the same platform as the script was generated on.
  • Enter the path for the platform driver (e). If using Chrome then enter the path of a compatible chromedriver.exe. If using Firefox then enter the path of the geckodriver.exe
  • Enter the path of the Webdriver.dll (f) to add it to the list of referenced assemblies so the component will compile successfully. Webdriver.dll can be downloaded from here.
  • Click the OK button to open the new Selenium component code in the editor.


Adding path of chromedriver.exe/geckodriver.exe and Webdriver.dll needs to be done once per test. Also, both paths are cached for future test use.

The new Selenium component comes with code to initialize the WebDriver for every VU when the test starts, and dispose the WebDriver when the test ends. The sample code is below:

#region Initialize/Dispose

	IWebDriver driver;
	IJavaScriptExecutor js;

	/// <summary>
	/// Fired when test started.
	/// </summary>
	public override void OnTestStart() {

	void InitChromeDriver() {
		ChromeDriverService service =
			ChromeDriverService.CreateDefaultService(System.IO.Path.Combine(this.RuntimeVU.TestDirectory, @"Scripts\selenium"));
		service.HideCommandPromptWindow = true;

		ChromeOptions options = new ChromeOptions();
		options.AddArguments(new List<string>() {
				//"headless" //uncomment to hide browser window.

		driver = new ChromeDriver(service, options);
		js = (IJavaScriptExecutor) driver;

	/// <summary>
	/// Fired when test ends.
	/// </summary>
	public override void OnTestEnd() {


Creating selenium transactions

The existing Selenium script must be copied into one or more action methods. Each method will represent a transaction that will later be added to the test case tree and appear on the test run report. Below is an example:

  	/// <summary>
	/// Direct the driver to navigate to our website.
	/// </summary>
	/// <param name="arg"></param>
	public void NavigateToWebsite(ActionArgs arg)

	/// <summary>
	/// Direct the driver to click on a link.
	/// </summary>
	/// <param name="arg"></param>
	public void ClickOnALink(ActionArgs arg)
  		driver.FindElement(By.LinkText("My Link")).Click();

Adding transactions by highlighting code

Another way to add action methods to an existing Selenium script is to do the following:

  1. Copy and paste the entire Selenium into the class definition inside the editor.
  2. Select a code snipet snippet to add to an action method
  3. Click the Create an action method from selected script button to bring up the surround with helper
  4. Select the action, click, or navigate option to create an appropriate action method with the selected code inside
  5. Give the action method a name
  6. Repeat steps 2-5 until all the code is inside appropriate action methods.

Creating transactions from the action methods

To automatically create transactions and containing action objects on the test case tree click the Compile the Selenium component and add actions to the current test case button. 

  • No labels