protected void DriverDownloadTest(IDriverConfig driverConfig) { new DriverManager().SetupLatestDriver(Directory.GetCurrentDirectory(), driverConfig); var pathVariable = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process); Assert.NotNull(pathVariable); Assert.Contains(driverConfig.GetName(), pathVariable); }
protected void BrowserTest(IDriverConfig driverConfig, DriverType driverType, string driverExe, string browserExe) { _driverExe = driverExe; _browserExe = browserExe; new DriverManager().SetUpDriver(driverConfig); _webDriver = new DriverCreator().Create(driverType); _webDriver.Navigate().GoToUrl("https://www.wikipedia.org"); Assert.Equal("Wikipedia", _webDriver.Title); }
protected void VersionTest(IDriverConfig driverConfig, string pattern) { var version = driverConfig.GetLatestVersion(); var regex = new Regex(pattern); var match = regex.Match(version); Assert.NotEmpty(version); Assert.True(match.Success); }
public static string DriverDirectoryFullPath(this IDriverConfig driverConfig) { if (driverConfig == null) { throw new ArgumentNullException(nameof(driverConfig)); } return(Path.Combine(Environment.CurrentDirectory, driverConfig.GetName(), driverConfig.GetLatestVersion(), $"{ArchitectureHelper.GetArchitecture():F}")); }
protected Fabric(string browserName, IDriverConfig config, Func <DriverOptions, IWebDriver> driverCreator) { if (driverCreator == null) { throw new ArgumentNullException(); } this.config = config; this.driverCreator = driverCreator; this.BrowserName = browserName; }
private static string GetVersionToDownload(IDriverConfig config, string version) { switch (version) { case VersionResolveStrategy.MatchingBrowser: return(config.GetMatchingBrowserVersion()); case VersionResolveStrategy.Latest: return(config.GetLatestVersion()); default: return(version); } }
private DriverProvider( IScriptLogger logger, CustomDriverManager customDriverManager, IDriverConfig driverConfig, DriverVersion driverVersion, Architecture architecture) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _customDriverManager = customDriverManager ?? throw new ArgumentNullException(nameof(customDriverManager)); _driverConfig = driverConfig ?? throw new ArgumentNullException(nameof(driverConfig)); _driverVersion = driverVersion ?? throw new ArgumentNullException(nameof(driverVersion)); _architecture = architecture; }
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()); }
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()); } } }
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()); } }
/// <summary> /// Initialise a <see cref="ManagedWebDriverFactory"/> with a specified <see cref="Browser"/>, <see cref="DriverOptions"/> and <see cref="IDriverConfig"/> for that browser /// </summary> /// <param name="browser">The browser to use</param> /// <param name="options">The options for the browser. You should provide a derived version of <see cref="DriverOptions"/> for the browser you want to use, e.g. <see cref="ChromeOptions"/></param> /// <param name="config">The config for the web driver. You should provide an implementation of <see cref="IDriverConfig"/> for the browser you want to use, e.g. <see cref="ChromeConfig"/></param> public ManagedWebDriverFactory(Browser browser, DriverOptions options, IDriverConfig config) { _browser = browser; _manager = new DriverManager(); _configs = new Dictionary <Browser, IDriverConfig> { { Browser.Chrome, new ChromeConfig() }, { Browser.Firefox, new FirefoxConfig() }, { Browser.Opera, new OperaConfig() }, { Browser.IE, new InternetExplorerConfig() }, { Browser.Edge, new EdgeConfig() } }; _options = new Dictionary <Browser, DriverOptions> { { Browser.Chrome, new ChromeOptions() }, { Browser.Firefox, new FirefoxOptions() }, { Browser.Opera, new OperaOptions() }, { Browser.IE, new InternetExplorerOptions() }, { Browser.Edge, new EdgeOptions() } }; if (config != null) { try { _configs[browser] = config; } catch (KeyNotFoundException) { throw new NotSupportedException(browser.ToString()); } } if (options != null) { try { _options[browser] = options; } catch (KeyNotFoundException) { throw new NotSupportedException(browser.ToString()); } } }
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 DriverProvider Create( IScriptLogger logger, FilePath driverPath, FileName driverExecutableName, IDriverConfig driverConfig, DriverVersion driverVersion, Architecture architecture = Architecture.Auto) { var driverManager = CustomDriverManager.Create(driverPath, driverExecutableName); return(new DriverProvider( logger: logger, customDriverManager: driverManager, driverConfig: driverConfig, driverVersion: driverVersion, architecture: architecture )); }
/// <summary> /// Using the Web Driver Manager /// </summary> private static void UsingDriverManager(DriverOption driverOption) { IWebDriver webDriver = null; IDriverConfig driverConfig = null; switch (driverOption) { case DriverOption.Chrome: driverConfig = new ChromeConfig(); webDriver = new ChromeDriver(); break; case DriverOption.Edge: driverConfig = new EdgeConfig(); webDriver = new EdgeDriver(); break; case DriverOption.Firefox: driverConfig = new FirefoxConfig(); webDriver = new FirefoxDriver("./"); break; case DriverOption.IE: driverConfig = new InternetExplorerConfig(); webDriver = new InternetExplorerDriver(); break; case DriverOption.Opera: driverConfig = new OperaConfig(); webDriver = new OperaDriver(); break; } new DriverManager().SetUpDriver(driverConfig); webDriver.Navigate().GoToUrl("https://www.google.com"); System.Console.WriteLine($"Title : {webDriver.Title}"); webDriver.Quit(); }
public void SetupLatestDriver(string workingDirectory, IDriverConfig browserConfig, bool use32bit = true, WDMProxy proxy = null) { SetupCompatibleDriver(workingDirectory, browserConfig, "Latest", use32bit, proxy); }
/// <summary> /// Initialise a <see cref="ManagedWebDriverFactory"/> with a specified <see cref="Browser"/> and <see cref="IDriverConfig"/> for that browser /// </summary> /// <param name="browser">The browser to use</param> /// <param name="config">The config for the web driver. You should provide an implementation of <see cref="IDriverConfig"/> for the browser you want to use, e.g. <see cref="ChromeConfig"/></param> public ManagedWebDriverFactory(Browser browser, IDriverConfig config) : this(browser, null, config) { }
public SeleniumDriverService(IDriverConfig driverConfig) { _driverConfig = driverConfig; }
protected void DriverDownloadTest(IDriverConfig driverConfig) { new DriverManager().SetUpDriver(driverConfig); }
public static string DriverFileFullPath(this IDriverConfig driverConfig) { return(Path.Combine(driverConfig.DriverDirectoryFullPath(), driverConfig.GetBinaryName())); }
public FooLiveCollection(ILog logger, IDriverConfig config) {
public SeleniumDriverManager(IDriverConfig driverConfig, SeleniumDriverService seleniumDriverService) { _driverConfig = driverConfig ?? throw new ArgumentNullException(nameof(driverConfig)); _seleniumDriverService = seleniumDriverService ?? throw new ArgumentNullException(nameof(seleniumDriverService)); SetupDriver(); }
private void SetupConfig(IDriverConfig config) { new DriverManager().SetUpDriver(config, "Latest", Architecture.X32); }