Example #1
0
        protected string Start(string programFiles)
        {
            var driverFile  = SeleniumFactory.GetWebDriverLocation(null, DriverFileName);
            var browserFile = GetBrowserFile(programFiles);

            if (browserFile?.Exists ?? false)
            {
                var browserVersion = GetBrowserVersion(browserFile);
                var driverVersion  = GetDriverVersion(driverFile);
                if (NeedUpdate(browserVersion, driverVersion))
                {
                    var versions          = SearchDriverVersions(browserVersion.Split('.'));
                    var versaoEscolhida   = ChooseBetterDriverVersion(versions);
                    var arquivoZip        = DownloadDriver(versaoEscolhida, new DirectoryInfo(RootPath));
                    var arquivoExe        = Unzip(arquivoZip);
                    var webDriverLocation = SeleniumFactory.GetWebDriverLocation(arquivoExe, DriverFileName);
                    if ((driverFile != null) && (driverFile.Directory.FullName != webDriverLocation.Directory.FullName))
                    {
                        webDriverLocation.CopyTo(driverFile.FullName, true);
                    }

                    return(Start(programFiles));
                }
                else
                {
                    return($"Atualizado! \r\n {DriverName}BrowserVersion: {browserVersion} \r\n {DriverName}DriverVersion: {driverVersion} ");
                }
            }

            return($"Baixe e instale o {DriverName}!");
        }
Example #2
0
        private FileInfo GetBrowserFile(string programFiles)
        {
            var fileInfo = new FileInfo(Path.Combine(@"C:\", programFiles, DefaultBrowserPath));
            var location = SeleniumFactory.GetWebDriverLocation(fileInfo, BrowserFileName);

            return((location?.Exists).GetValueOrDefault() ? location : null);
        }