Пример #1
0
        public void SetUpDriver(IDriverConfig config, string version = "Latest",
                                Architecture architecture            = Architecture.Auto)
        {
            architecture = architecture.Equals(Architecture.Auto) ? ArchitectureHelper.GetArchitecture() : architecture;
            version      = version.Equals("Latest") ? config.GetLatestVersion() : version;
            var url = architecture.Equals(Architecture.X32) ? config.GetUrl32() : config.GetUrl64();

            url = UrlHelper.BuildUrl(url, version);
            var binaryPath = FileHelper.GetBinDestination(config.GetName(), version, architecture,
                                                          config.GetBinaryName());

            SetUpDriver(url, binaryPath, config.GetBinaryName());
        }
 public void SetUpDriver(IDriverConfig config, string version = VersionResolveStrategy.Latest,
                         Architecture architecture            = Architecture.Auto)
 {
     lock (Object)
     {
         architecture = architecture.Equals(Architecture.Auto)
             ? ArchitectureHelper.GetArchitecture()
             : architecture;
         version = GetVersionToDownload(config, version);
         var url = architecture.Equals(Architecture.X32) ? config.GetUrl32() : config.GetUrl64();
         url = UrlHelper.BuildUrl(url, version);
         var binaryPath = FileHelper.GetBinDestination(config.GetName(), version, architecture,
                                                       config.GetBinaryName());
         SetUpDriver(url, binaryPath, config.GetBinaryName());
     }
 }
Пример #3
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);
            }
        }
Пример #4
0
        private static void SetUpDriver(IDriverConfig driverConfig, IDriverSettings driverSettings)
        {
            var architecture = driverSettings.SystemArchitecture.Equals(Architecture.Auto) ? ArchitectureHelper.GetArchitecture() : driverSettings.SystemArchitecture;
            var version      = driverSettings.WebDriverVersion.Equals("Latest") ? driverConfig.GetLatestVersion() : driverSettings.WebDriverVersion;
            var url          = UrlHelper.BuildUrl(architecture.Equals(Architecture.X32) ? driverConfig.GetUrl32() : driverConfig.GetUrl64(), version);
            var binaryPath   = FileHelper.GetBinDestination(driverConfig.GetName(), version, architecture, driverConfig.GetBinaryName());

            if (!File.Exists(binaryPath) || !Environment.GetEnvironmentVariable("PATH").Contains(binaryPath))
            {
                lock (WebDriverDownloadingLock)
                {
                    new DriverManager().SetUpDriver(url, binaryPath, driverConfig.GetBinaryName());
                }
            }
        }
Пример #5
0
        public List <Tuple <string, string> > GetDriverInfo(IDriverConfig browserConfig, Architecture architecture, string browserVersion)
        {
            var baseUrlForSelectedArchitecture = architecture.Equals(Architecture.X32) ? browserConfig.GetUrl32() : browserConfig.GetUrl64();

            browserVersion = browserVersion.Equals("Latest", StringComparison.InvariantCultureIgnoreCase) ? browserVersion : CompatibilityHelper.GetMajorVersion(browserVersion);

            var driverVersion = browserConfig.GetDriverVersion(browserVersion);

            var url = UrlHelper.BuildUrl(baseUrlForSelectedArchitecture, driverVersion);

            var fileAndFolderPath = FileHelper.GetDriverDestination(browserConfig.GetName(), driverVersion, architecture, browserConfig.GetBinaryName());

            List <Tuple <string, string> > driverInfo = new List <Tuple <string, string> >();

            driverInfo.Add(new Tuple <string, string>(url, fileAndFolderPath));

            return(driverInfo);
        }
 public static string DriverFileFullPath(this IDriverConfig driverConfig)
 {
     return(Path.Combine(driverConfig.DriverDirectoryFullPath(), driverConfig.GetBinaryName()));
 }