I have automated regression tests that run every morning. Currently, it launches dozens of threads simultaneously, each running its own webdriver in each thread.
ChromeOptions option = new ChromeOptions();
option.AddArgument("--headless");
IWebDriver driver = new ChromeDriver(option);
try
{
SuiteDriver(driver, suiteTable);
LogMonitor.UEErrorHandling();
}
catch (Exception ex)
{
WritetoLogFile("Exception in Main - " + ex);
}
finally
{
workbook.Dispose();
driver.Quit();
}
When the tests complete there are a bunch of webdriver instances still running. When I attempt to clean these up at the end of the test run using driver.Quit() it closes more than just the driver in its own thread, causing the other tests to fail to complete. Driver.Quit() doesn't seem to differentiate between the driver launched by this one instance and other drivers launched by other instances of the test.
Is there a way to ensure driver.Quit() or driver.Close() only closes the instance of webdriver launched by that specific executable running in that thread only?