private static IWebDriver CreateFirefoxDriver(params string[] addArgument) { var options = new FirefoxOptions { BrowserVersion = "79.0", PlatformName = "WINDOWS" }; options.AddArgument("--start-maximized"); if (Config.IsHeadless) { options.AddArgument("headless"); } if (addArgument.Length > 0) { foreach (var argument in addArgument) { options.AddArgument(argument); } } var remoteSettings = new RemoteSessionSettings(options); var uri = new Uri(Config.RemoteWebDriverAddress); var drv = new RemoteWebDriver(uri, remoteSettings) { FileDetector = new LocalFileDetector() }; return(drv); }
public static IWebDriver CreateRemoteDriver(this WebDriverConfig config) { config.ValidateNotNull(nameof(config)); config.ValidateDriverName("Remote"); Uri driverUri; if (config.DriverLocation == null) { driverUri = new Uri("http://127.0.0.1:4444/wd/hub/"); } else { driverUri = new Uri(config.DriverLocation); } var capabilities = new RemoteSessionSettings(); if (config.Capabilities != null) { foreach (var capability in config.Capabilities) { capabilities.AddMetadataSetting(capability.Key, capability.Value); } } var commandTimeout = GetCommandTimeout(config); return(new RemoteWebDriver(driverUri, capabilities, commandTimeout) .ApplyCommon(config)); }
private static IWebDriver CreateChromeDriver(params string[] addArgument) { var options = new ChromeOptions { BrowserVersion = "84.0.4147.89", PlatformName = "WINDOWS" }; options.AddUserProfilePreference("download.default_directory", Config.DownloadsFolder); options.AddUserProfilePreference("prompt_for_download", false); options.AddArgument("--start-maximized"); if (Config.IsHeadless) { options.AddArgument("headless"); } if (addArgument.Length > 0) { foreach (var argument in addArgument) { options.AddArgument(argument); } } var remoteSettings = new RemoteSessionSettings(options); var uri = new Uri(Config.RemoteWebDriverAddress); var drv = new RemoteWebDriver(uri, remoteSettings) { FileDetector = new LocalFileDetector() }; return(drv); }
private static IWebDriver RemoteWebDriver(BrowserStack browserStack) { var caps = new RemoteSessionSettings(); caps.AddMetadataSetting("browserstack.user", browserStack.User.Value); caps.AddMetadataSetting("browserstack.key", browserStack.Key.Value); caps.AddMetadataSetting("browserstack.debug", true); foreach (var key in browserStack.Environment.Value.AllKeys) { caps.AddMetadataSetting(key, browserStack.Environment.Value[key]); } return(new RemoteWebDriver(browserStack.Url.Value, caps)); }
public void Init() { var caps = new RemoteSessionSettings(); caps.AddMetadataSetting("platform", "WIN10"); caps.AddMetadataSetting("browserName", "chrome"); caps.AddMetadataSetting("version", "79"); caps.AddMetadataSetting("deviceName", deviceName); caps.AddMetadataSetting("deviceOrientation", deviceOrientation); caps.AddMetadataSetting("client_key", "ab220ca5b1b949f9b6b750b800fb6d2d"); caps.AddMetadataSetting("client_secret", "6ef2e9f8186691f40bd886604e7b6e41"); caps.AddMetadataSetting("name", TestContext.CurrentContext.Test.Name); _driver = new RemoteWebDriver(new Uri("https://hub.testingbot.com/wd/hub"), caps, TimeSpan.FromSeconds(600)); }
public void Test1() { // Maven with Selenium Automation and Chrome Driver // class needed to used is: RemoteWebDriver // Declare what browser. (.chrome, .firefox..), What URL and pass thru driver. RemoteSessionSettings cap = new RemoteSessionSettings(); using (RemoteWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), cap)) { // fetch / get a web site driver.Navigate().GoToUrl("http://careerdevs.com"); // Console out the title of the Web Site System.Console.WriteLine(driver.Title); } }
public void Initialize() { var caps = new RemoteSessionSettings(); caps.AddMetadataSetting("name", "NUnit Test"); caps.AddMetadataSetting("username", username); caps.AddMetadataSetting("password", authkey); caps.AddMetadataSetting("platform", "Windows 10"); switch (browser) { // These all pull the latest version by default // To specify version add SetCapability("version", "desired version") case "chrome": caps.AddMetadataSetting("browserName", "Chrome"); break; case "ie": caps.AddMetadataSetting("browserName", "Internet Explorer"); break; case "edge": caps.AddMetadataSetting("browserName", "MicrosoftEdge"); break; case "firefox": caps.AddMetadataSetting("browserName", "Firefox"); break; default: caps.AddMetadataSetting("browserName", "Chrome"); break; } driver = new RemoteWebDriver(new Uri("http://hub.crossbrowsertesting.com:80/wd/hub/"), caps); }
/// <summary> /// Creates a new WebDriver instance for one of the major web /// browsers. Will wrap the driver in an /// <see cref="EventFiringWebDriver"/>. /// </summary> /// <param name="majorWebDriver"></param> /// <param name="windowSize"></param> /// <param name="track"> /// If false, will not dispose the driver when the factory is /// disposed. /// </param> /// <returns></returns> public IWebDriver CreateDriver(MajorWebDriver majorWebDriver, Size windowSize, bool track = true) { var driver = default(IWebDriver); var driverOpts = default(DriverOptions); var driverConfig = default(IDriverConfig); switch (majorWebDriver) { case MajorWebDriver.Chrome: driverConfig = new ChromeConfig(); driverOpts = new ChromeOptions(); break; case MajorWebDriver.Edge: driverConfig = new EdgeConfig(); driverOpts = new EdgeOptions(); break; case MajorWebDriver.Firefox: driverConfig = new FirefoxConfig(); driverOpts = new FirefoxOptions(); break; case MajorWebDriver.InternetExplorer: driverConfig = new InternetExplorerConfig(); driverOpts = new InternetExplorerOptions(); break; default: throw new NotImplementedException(); } // Download driver if not available locally. driverManager.SetUpDriver(driverConfig); if (isStandalone) { switch (majorWebDriver) { case MajorWebDriver.Chrome: { var opts = driverOpts as ChromeOptions; opts.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"; driver = new ChromeDriver(opts); break; } case MajorWebDriver.Edge: { driver = new EdgeDriver(); break; } case MajorWebDriver.Firefox: { var opts = driverOpts as FirefoxOptions; opts.BrowserExecutableLocation = @"C:\Program Files\Mozilla Firefox\firefox.exe"; driver = new FirefoxDriver(opts); break; } case MajorWebDriver.InternetExplorer: { driver = new InternetExplorerDriver(); break; } default: throw new NotImplementedException(); } } else { var d = new RemoteSessionSettings(); d.AddFirstMatchDriverOption(driverOpts); driver = new RemoteWebDriver(d); } // Set the window size. driver.Manage().Window.Size = windowSize; // Wrap with EventFiringWebDriver. //driver = new EventFiringWebDriver(driver); if (track) { trackedDrivers.Add(driver); } return(driver); }
public CrossBrowserTestingConfig(CrossBrowserTestingUser user, RemoteSessionSettings sessionSettings) { this.SessionSettings = sessionSettings; this.SessionSettings.AddMetadataSetting("username", user.Username); this.SessionSettings.AddMetadataSetting("password", user.Authkey); }