private void InitializeWebDriver(WebDriverType driverToUse) { try { _webDriver = new WebDriver(driverToUse); } catch (Exception ex) { _log.FatalFormat("Could not instatiate driver {0}. Did you download the required executables? \n{1}", driverToUse.ToString(), ex.Message); throw (ex); } }
/// <summary> /// Determine and instantiate the specified web driver. /// Default to headless if no driver is defined. /// </summary> /// <param name="xmlDoc">loaded xml document to scan for driver definition.</param> private void DefineDriver(XmlDocument xmlDoc) { List<string> xmlDriver = PullFromXML(xmlDoc, "//test-attributes/web-driver"); if (xmlDriver.Count() == 0) _webDriver = new WebDriver(); else { string driverToUse = xmlDriver[0].ToLower(); if (0 == string.Compare(driverToUse, "chrome")) _webDriver = new WebDriver(WebDriverType.Chrome); else if (0 == string.Compare(driverToUse, "ie32")) _webDriver = new WebDriver(WebDriverType.Firefox); else if (0 == string.Compare(driverToUse, "headless")) _webDriver = new WebDriver(WebDriverType.Headless); else if (0 == string.Compare(driverToUse, "ie32")) _webDriver = new WebDriver(WebDriverType.IE32); else if (0 == string.Compare(driverToUse, "safari")) _webDriver = new WebDriver(WebDriverType.Safari); else { _log.WarnFormat("Did not understand driver type {0}. Using default.", driverToUse); _webDriver = new WebDriver(); } } }