-1

I Need to executed selenium UI tests using selenium grid on multiple node with different configurations. Currently I am able to execute tests only on one machine at the give time using the RemoteWebDriver and desired capabilities. My Code is as follows:

using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Remote;
using System;
using System.Collections.Generic;

namespace ClassLibrary1.Test
{
[TestFixture]

public class Test1 : BaseTestClass
{
    public RemoteWebDriver driver = null;
    [SetUp] 
    public void setup()
    {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.SetCapability(CapabilityType.BrowserName, "chrome");
        capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));

        driver = new RemoteWebDriver(new Uri(" http://152.17.100.217:5454/wd/hub"), capabilities);
        driver.Manage().Window.Maximize();
    }
    [TearDown] 
    public void teardown()
    {
        driver.Quit();
    }
    [Test]
    //[Parallelizable]
    public void test1()
    {


        driver.Navigate().GoToUrl("https://www.google.com");
        Thread.Sleep(5000);
        IWebElement query = driver.FindElement(By.Name("q"));
        query.SendKeys("test");
        query.Submit();
        Thread.Sleep(15000);

    }
    [Test]
    //[Parallelizable]
    public void test2()
    {

        driver.Navigate().GoToUrl("https://www.google.com");
        Thread.Sleep(5000);
        IWebElement query = driver.FindElement(By.Name("q"));
        query.SendKeys("selenium ");
        query.Submit();
        Thread.Sleep(15000);

    }

}
  }

I need to execute around 250+ tests on servers via VSTS and also need to implement the selenium grid for different configurations. With this I am only able to execute these tests on one server at a time then I need to change the capabilities manually to execute it on another server. What can I do to make it run on multiple machine at same time. I know that is possible with Java using the xml file and adding the nodes for machine configurations and tests files but not able to do it using c#. After that I intend to trigger this using the VSTS build. Is there any way to achieve it ??

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Ak02
  • 143
  • 4
  • 16
  • A lot of this setup needs to be done through Selenium grid interface and not the code itself. Have you read their documentation? https://www.seleniumhq.org/docs/07_selenium_grid.jsp – CEH Sep 30 '19 at 17:09
  • Yes, I did that setup already and that is working fine with one node a time. But I need to execute the tests on multiple nodes at same time. that I am not able to achieve with c#. – Ak02 Oct 01 '19 at 05:51

2 Answers2

0

If you want to execute different capabilities on a per-server basis, you may need to use C# build configurations & XML transformations for this.

Your setup will work as follows:

  • Multiple .config files -- each config file contains capabilities for each server -- server1.config, server2.config, etc.

  • Run your tests against your desired .config file

That way, you can specify which capabilities you want to execute on a per-server basis.

You will need the SlowCheetah package extension for the XML transforms.

And you will need to read from the .configs using ConfigurationManager.AppSettings, specified here.

This is a generic answer for an open-ended question. A lot of this work and research will need to be done on your own. If you run into specific issues or error messages, you can open a new question here for more targeted troubleshooting.

CEH
  • 5,701
  • 2
  • 16
  • 40
0

In VSTS/Azure DevOps you can use slicing to distribute your execution load in multiple agents -> (https://learn.microsoft.com/en-gb/azure/devops/pipelines/process/phases?view=azure-devops&tabs=classic#slicing)

Excerpt:

An agent job can be used to run a suite of tests in parallel. For example, you can run a large suite of 1000 tests on a single agent. Or, you can use two agents and run 500 tests on each one in parallel.

zer0gr4v
  • 62
  • 3