public void BuildDriver() { string browserConfig = _configuration.GetSection("Selenium:browser").Value; Browsers browser = Enum.GetValues(typeof(Browsers)).Cast <Browsers>().ToList() .Where(b => b.ToString().ToUpper() == browserConfig.ToUpper()).First(); var sizeConfig = _configuration.GetSection("Selenium:screen"); var size = new Size(int.Parse(sizeConfig.GetSection("width").Value), int.Parse(sizeConfig.GetSection("height").Value)); bool isHeadless = bool.Parse(_configuration.GetSection("Selenium:headless").Value); _driver = WebDriverFactory.CreateDriverInstance(browser, size, isHeadless); }