Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
DriverSetup for SpecFlow parallelization
public class DriverSetup
private IObjectContainer _objectContainer;
public IWebDriver Driver;
public DriverSetup(IObjectContainer objectContainer)
_objectContainer = objectContainer;
public void BeforeScenario()
//TODO please supply your Sauce Labs user name in an environment variable
var sauceUserName = Environment.GetEnvironmentVariable("SAUCE_USERNAME", EnvironmentVariableTarget.User);
//TODO please supply your own Sauce Labs access Key in an environment variable
var sauceAccessKey = Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY", EnvironmentVariableTarget.User);
var sauceOptions = new Dictionary<string, object>
["username"] = sauceUserName,
["accessKey"] = sauceAccessKey
var chromeOptions = new ChromeOptions
BrowserVersion = "latest",
PlatformName = "Windows 10"
chromeOptions.AddAdditionalOption("sauce:options", sauceOptions);
Driver = new RemoteWebDriver(new Uri(""),
chromeOptions.ToCapabilities(), TimeSpan.FromSeconds(30));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment