Is there any way to run multiple tests in same browser using Webdriver (Selenium) using Xunit, , at present xunit launches new browser for every new test , below is the samp
IUseFixture
doesn't exist any more and seems replaced by IClassFixture. But I can't directly inject the FirefoxDriver
as posted by @Mark Seemann:
public class DashboardCategoryBoxes : IClassFixture {
IWebDriver driver;
public DashboardCategoryBoxes(FirefoxDriver driver) {
//this.driver = wrapper.Driver;
this.driver = driver;
}
}
This throw an error
System.AggregateException : One or more errors occurred. (Class fixture type 'OpenQA.Selenium.Firefox.FirefoxDriver' may only define a single public constructor.) (The following constructor parameters did not have matching fixture data: FirefoxDriver driver)
---- Class fixture type 'OpenQA.Selenium.Firefox.FirefoxDriver' may only define a single public constructor.
---- The following constructor parameters did not have matching fixture data: FirefoxDriver driver
As a workaround, we could create some wrapper class without constructor
public class FirefoxWrapper {
FirefoxDriver driver = new FirefoxDriver();
public FirefoxWrapper Driver {
get { return driver; }
}
}
and fetch the driver from there
public class DashboardCategoryBoxes : IClassFixture {
IWebDriver driver;
public DashboardCategoryBoxes(FirefoxWrapper wrapper) {
driver = wrapper.Driver;
}
}