Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 public void SetupLatestDriver(string workingDirectory, IDriverConfig browserConfig, bool use32bit = true, WDMProxy proxy = null)
 {
     SetupCompatibleDriver(workingDirectory, browserConfig, "Latest", use32bit, proxy);
 }