/// <summary> /// Initializes a new instance of the class.<see cref="EwsAdapter" /> /// </summary> /// <param name="settings">The settings.</param> public EwsAdapter(EwsSettings settings, EwsSeleniumSettings seleniumSettings, string siteMapPath) { if (settings == null) { throw new ArgumentNullException("settings"); } _settings = settings; if (settings.AdapterType == EwsAdapterType.SeleniumServerRC) { _client = new SeleniumServer ( CopyServerJarFile(seleniumSettings), settings.HttpRemoteControlHost, settings.HttpRemoteControlPort ); } else if (settings.AdapterType == EwsAdapterType.WebDriverAdapter) { _client = new SeleniumWebDriver(settings.Browser, CopyWebDriverEXEFiles(settings.Browser, seleniumSettings)); _client.PageNavigationDelay = settings.PageNavigationDelay; _client.ElementOperationDelay = settings.ElementOperationDelay; } _siteMapData = new EwsSiteMapData(settings, siteMapPath); }
/// <summary> /// Reads the file path from database and copy over the driver files for IE and Chrome. /// For IE, copies over the Driver file based on the processor type. /// For Chrome, copies over the 32-bit driver file as driver support is available only for 32-bit. /// </summary> /// <param name="browser">Browser model</param> /// <returns>Destination directory</returns> public static string CopyWebDriverEXEFiles(BrowserModel browser, EwsSeleniumSettings seleniumSettings) { if (browser == BrowserModel.Firefox) { return(string.Empty); } string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string destDirectory = Path.Combine(appDataPath, "SeleniumWebDriver"); string source = string.Empty; string destination = string.Empty; if (browser == BrowserModel.Explorer) { if (Environment.Is64BitOperatingSystem) { source = seleniumSettings.SeleniumIEDriverPath64; } else { source = seleniumSettings.SeleniumIEDriverPath32; } destination = Path.Combine(destDirectory, "IEDriverServer.exe"); } else if (browser == BrowserModel.Chrome) { source = seleniumSettings.SeleniumChromeDriverPath; destination = Path.Combine(destDirectory, Path.GetFileName(source)); } if (!Directory.Exists(destDirectory)) { Directory.CreateDirectory(destDirectory); } if (File.Exists(destination)) { File.Delete(destination); } File.Copy(source, destination, true); return(destDirectory); }
private static string CopyServerJarFile(EwsSeleniumSettings seleniumSettings) { // This ensures the Selenium RC jar file is on the local machine. Get the file from the // location specified in the settings and copy it to the location defined in the AppData directory. // Return this value as it is sent to the SeleniumServer class to tell it where to go to start the // server file. string source = seleniumSettings.SeleniumServerJarFile; string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SeleniumRC"); string destination = Path.Combine(directory, "SeleniumServer.jar"); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } if (!File.Exists(destination)) { File.Copy(source, destination, true); } return(destination); }