public void SetupCompatibleDriver(string workingDirectory, IDriverConfig browserConfig, string browserVersion, bool use32bit = true, WDMProxy proxy = null) { var driverArchitecture = use32bit ? Architecture.X32 : ArchitectureHelper.GetArchitecture(); List <Tuple <string, string> > driverInfo; driverInfo = GetDriverInfo(browserConfig, driverArchitecture, browserVersion); //these are all the variables we need to be setup var url = driverInfo[0].Item1; var driverLocation = Path.Combine(workingDirectory, driverInfo[0].Item2); if (File.Exists(driverLocation)) { SetUpLocalDriver(driverLocation); } else { var tempDirectory = FileHelper.GetTempDirectory(); var driverName = browserConfig.GetBinaryName(); var downloadedFileName = FileHelper.GetFileNameFromUrl(url); var zipLocation = ZipHelper.DownloadZip(url, tempDirectory, downloadedFileName, proxy); FileHelper.CreateDestinationDirectory(driverLocation); ZipHelper.UnZipToDriverLocation(zipLocation, driverLocation, driverName); ZipHelper.DeleteZip(zipLocation); SetUpLocalDriver(driverLocation); } }
public static string DownloadZip(string url, string tempDirectory, string fileName, WDMProxy proxy = null) { try { var zipFileLocation = Path.Combine(tempDirectory, fileName); if (!File.Exists(zipFileLocation)) { using (var webClient = new WebClient()) { if (proxy != null) { webClient.Proxy = proxy.userProxy; } webClient.DownloadFile(new Uri(url), zipFileLocation); if (!File.Exists(zipFileLocation)) { throw new FileNotFoundException(fileName + " was not downloaded to " + tempDirectory, fileName); } } } return(zipFileLocation); } catch (Exception ex) { throw new ArgumentException("Unable to download Zip", ex.InnerException); } }
public void SetupLatestDriver(string workingDirectory, IDriverConfig browserConfig, bool use32bit = true, WDMProxy proxy = null) { SetupCompatibleDriver(workingDirectory, browserConfig, "Latest", use32bit, proxy); }