/// <summary> /// Get the web driver location /// </summary> /// <param name="driverFile">The web drive file, including extension</param> /// <param name="defaultHintPath">The default location for the specific driver</param> /// <param name="mustExist">Do we need to know where this drive is located, if this is true and the file is not found an error will be thrown</param> /// <returns>The path to the web driver</returns> private static string GetDriverLocation(string driverFile, string defaultHintPath = "", bool mustExist = true) { // Get the hint path from the app.config string hintPath = SeleniumConfig.GetDriverHintPath(); // Try the hintpath first if (!string.IsNullOrEmpty(hintPath) && File.Exists(Path.Combine(hintPath, driverFile))) { return(hintPath); } // Try the default hit path next if (!string.IsNullOrEmpty(defaultHintPath) && File.Exists(Path.Combine(defaultHintPath, driverFile))) { return(Path.Combine(defaultHintPath).ToString()); } // Get the test dll location UriBuilder uri = new UriBuilder(Assembly.GetExecutingAssembly().Location); string testLocation = Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path)); // Try the test dll location if (File.Exists(Path.Combine(testLocation, driverFile))) { return(testLocation); } // We didn't find the web driver so throw an error if we need to know where it is if (mustExist) { throw new FileNotFoundException(StringProcessor.SafeFormatter("Unable to find driver for '{0}'", driverFile)); } return(string.Empty); }