Originally posted by **harimadusumilli** November 8, 2021
Running Parallel Tests in Gauge using Selenium seems to execute in series although browser launches in parallel.
environment : Windows 10 & Ubuntu Linux container too.
Gauge version: 1.1.8
Commit Hash: b1501f4
Plugins
-------
dotnet (0.4.1)
html-report (4.0.12)
js (2.3.15)
json-report (0.3.5)
screenshot (0.0.1)
xml-report (0.2.3)
In the default. properties file we have also added the following entry:
enable_multithreading = true
Three spec files
We are running three spec files which contain the same navigation steps.
and are running them as below:
gauge run specs -p -n=4 --verbose
We are using static webdriver instance, this appears to conflict and creates in consistency while running it. The behavior appears to be erratic, for e.g:, we notice that the data is input incorrectly to a test case as the web driver appears to be key in the test data into only the browser it has a handle instead of their respective browser instances.
Code is as below:
using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Gauge.CSharp.Lib;
using Gauge.CSharp.Lib.Attribute;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System.Threading;
namespace DefaultProj
{
public class StepImplementation
{
//This is the static webdriver
private static IWebDriver seleniumDriver;
public void initWebDriver(){
seleniumDriver = new ChromeDriver(Environment.CurrentDirectory + "/Selenium Drivers");
((IJavaScriptExecutor)seleniumDriver).ExecuteScript("window.focus();");
seleniumDriver.Manage().Window.Maximize();
}
public void LaunchApp(){
seleniumDriver.Navigate().GoToUrl("https://our_intranet_app.net/");
}
[Step("search with name ")]
public void SearchWithName(string name)
{
try{
this.initWebDriver();
this.LaunchApp();
seleniumDriver.FindElement(By.Id("search-inside-textbox")).SendKeys(name);
seleniumDriver.FindElement(By.XPath("//span[@class='icon icon-search']")).Click();
GaugeMessages.WriteMessage("Name search");
GaugeScreenshots.Capture();
seleniumDriver.Close();
}
catch(Exception e){
Console.WriteLine(e.Message);
seleniumDriver.Close();
}
}
}
}
Discussed in https://github.com/getgauge/gauge/discussions/2157