public override IWebDriver factoryMethod() { EdgeOptions options = new EdgeOptions(); options.PageLoadStrategy = EdgePageLoadStrategy.Eager; string serverPath = System.Environment.ExpandEnvironmentVariables("C:\\Program Files (x86)\\Microsoft Web Driver"); driver = new EdgeDriver(serverPath, options); driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(10)); return driver; }
static void Main(string[] args) { RemoteWebDriver driver = null; string serverPath = "Microsoft Web Driver"; try { if (System.Environment.Is64BitOperatingSystem) { serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), serverPath); } else { serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles%"), serverPath); } // location for MicrosoftWebDriver.exe EdgeOptions options = new EdgeOptions(); options.PageLoadStrategy = EdgePageLoadStrategy.Eager; driver = new EdgeDriver(serverPath, options); //Set page load timeout to 5 seconds driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(5)); // Navigate to https://www.bing.com/ driver.Url = "https://www.bing.com/"; //// Find the search box and query for webdriver RemoteWebElement element = (RemoteWebElement)driver.FindElementById("sb_form_q"); element.SendKeys("webdriver"); element.SendKeys(Keys.Enter); // Wait for search result WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5)); wait.Until(x => x.Title.Contains("webdriver")); Screenshot shot = driver.GetScreenshot(); shot.SaveAsFile("output.png", ImageFormat.Png); } catch (Exception e) { Console.WriteLine(e.Message); } finally { if (driver != null) { driver.Close(); } } }
/// <summary> /// Gets the web driver for standalone browsers. /// </summary> /// <param name="testSettings">The test settings.</param> /// <param name="browserVersion">The browser version.</param> /// <param name="testOutputHelper">The test output helper.</param> /// <returns></returns> public static ITestWebDriver InitializeStandaloneBrowserDriver(TestSettings testSettings, decimal browserVersion, ITestOutputHelper testOutputHelper) { ScreenShotCounter = 0; TestOutputHelper = testOutputHelper; testSettings = ValidateSavePaths(testSettings); switch (testSettings.DriverType) { case WebDriverType.ChromeDriver: { string driverLocation; switch (browserVersion.ToString(CultureInfo.InvariantCulture)) { case "48": case "47": case "46": case "45": case "44": case "43": driverLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\Drivers\\ChromeDrivers\\2.20\\chromedriver.exe"; break; case "42": case "41": case "40": case "39": driverLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\Drivers\\ChromeDrivers\\2.14\\chromedriver.exe"; break; case "38": case "37": case "36": driverLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\Drivers\\ChromeDrivers\\2.11\\chromedriver.exe"; break; case "35": case "34": case "33": driverLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\Drivers\\ChromeDrivers\\2.10\\chromedriver.exe"; break; case "32": case "31": case "30": driverLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\Drivers\\ChromeDrivers\\2.8\\chromedriver.exe"; break; default: driverLocation = Path.Combine(AssemblyDirectory, "chromedriver.exe"); break; } ValidateDriverPresentOrUnblocked(WebDriverType.ChromeDriver, driverLocation); testSettings.BrowserName = "Chrome " + browserVersion; var multiBrowserExe = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\MB_Chrome" + browserVersion + ".exe"; var driverService = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverLocation), Path.GetFileName(driverLocation)); var options = new ChromeOptions { LeaveBrowserRunning = false, BinaryLocation = multiBrowserExe }; options.AddArgument("--no-default-browser-check"); options.AddArgument("--test-type=browser"); options.AddArgument("--start-maximized"); options.AddArgument("--allow-no-sandbox-job"); options.AddArgument("--disable-component-update"); options.AddArgument("--auth-server-whitelist=" + testSettings.TestUri.Authority.Replace("www", "*")); var driver = new ChromeDriver(driverService, options, testSettings.TimeoutTimeSpan); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } case WebDriverType.FirefoxDriver: { testSettings.BrowserName = "Firefox " + browserVersion; var multiBrowserExe = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\MB_Chrome" + browserVersion + ".exe"; var driverService = FirefoxDriverService.CreateDefaultService(); driverService.FirefoxBinaryPath = multiBrowserExe; var options = new FirefoxOptions(); var driver = new FirefoxDriver(driverService, options, testSettings.TimeoutTimeSpan); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } case WebDriverType.InternetExplorerDriver: { testSettings.BrowserName = "IE " + browserVersion; string driverLocation; if (!Environment.Is64BitProcess) { driverLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\Drivers\\IEDrivers\\x86\\IEDriverServer.exe"; } else { driverLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\Drivers\\IEDrivers\\x64\\IEDriverServer64.exe"; } var driverService = InternetExplorerDriverService.CreateDefaultService(Path.GetDirectoryName(driverLocation), Path.GetFileName(driverLocation)); var options = new InternetExplorerOptions { IgnoreZoomLevel = true, IntroduceInstabilityByIgnoringProtectedModeSettings = true, BrowserAttachTimeout = testSettings.TimeoutTimeSpan, RequireWindowFocus = true, ElementScrollBehavior = InternetExplorerElementScrollBehavior.Bottom, InitialBrowserUrl = testSettings.TestUri.AbsoluteUri, EnsureCleanSession = true, EnableNativeEvents = true }; var driver = new InternetExplorerDriver(driverService, options, testSettings.TimeoutTimeSpan); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } case WebDriverType.EdgeDriver: { testSettings.BrowserName = "Edge " + browserVersion; var driverService = EdgeDriverService.CreateDefaultService(AssemblyDirectory, "MicrosoftWebDriver.exe"); var options = new EdgeOptions { PageLoadStrategy = EdgePageLoadStrategy.Default }; var driver = new EdgeDriver(driverService, options, testSettings.TimeoutTimeSpan); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } case WebDriverType.OperaDriver: { testSettings.BrowserName = "Opera " + browserVersion; var multiBrowserExe = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\MB_Chrome" + browserVersion + ".exe"; var driverService = OperaDriverService.CreateDefaultService(); var options = new OperaOptions { LeaveBrowserRunning = false, BinaryLocation = multiBrowserExe }; var driver = new OperaDriver(driverService, options, testSettings.TimeoutTimeSpan); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } case WebDriverType.SafariDriver: { testSettings.BrowserName = "Firefox " + browserVersion; var multiBrowserExe = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\MB_Chrome" + browserVersion + ".exe"; var options = new SafariOptions { SafariLocation = multiBrowserExe }; var driver = new SafariDriver(options); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } } return null; }
static void Main(string[] args) { Console.Write("Release: "); var release = Console.ReadLine(); Console.Write("Environment: "); var environment = Console.ReadLine(); Console.Write("Cluster (optional):"); var cluster = Console.ReadLine(); Console.WriteLine("Starting Edge automation."); Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); if (!string.IsNullOrWhiteSpace(UserConfig.Instance.ErrorLog)) { Trace.Listeners.Add(new TextWriterTraceListener(UserConfig.Instance.ErrorLog)); } UserConfig.Instance.Reload(); var now = DateTime.Now; var yearWeek = DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(now, CalendarWeekRule.FirstDay, DayOfWeek.Sunday); var releaseName = $"{now.ToString("yy")}.{yearWeek} {release}"; var runDateAndHour = now.ToString("MM-dd-yyyy HH"); try { var serverPath = Path.Combine(Environment.ExpandEnvironmentVariables($"{((Environment.Is64BitOperatingSystem) ? "%ProgramFiles(x86)%" : "%ProgramFiles%")}"), Properties.Settings.Default.WebDriverName); var options = new EdgeOptions { PageLoadStrategy = EdgePageLoadStrategy.Normal }; var sites = UserConfig.Instance.Sites.Where(s => string.IsNullOrWhiteSpace(cluster) || s.Cluster.Equals(cluster, StringComparison.OrdinalIgnoreCase)).ToList(); var pages = UserConfig.Instance.Pages.ToList(); using (var driver = new EdgeDriver(serverPath, options)) { //This doesn't seem to work yet? //driver.Manage().Window.Maximize(); //driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 15)); for (var s = 0; s < sites.Count(); s++) { var site = sites[s]; Console.WriteLine("------------------------------------"); Console.WriteLine($"Site {s+1} of {sites.Count()}"); Console.WriteLine(); Console.WriteLine(site.Name); foreach (Page page in pages) { try { Console.WriteLine($" {page.Name}"); driver.Navigate().GoToUrl($"{site.BaseUrl}{page.Suffix}"); Thread.Sleep(5000); var imagePath = Path.Combine(UserConfig.Instance.ScreenShotPath, releaseName, environment, runDateAndHour, "Desktop", $"{site.Name} {page.Name} edge.png"); Directory.CreateDirectory(Path.GetDirectoryName(imagePath)); var screenshot = driver.GetScreenshot(); screenshot.SaveAsFile(imagePath, System.Drawing.Imaging.ImageFormat.Png); } catch (Exception e) { Trace.WriteLine(e.Message); } } Console.WriteLine(); } } } catch (Exception e) { Trace.WriteLine(e.Message); } Console.WriteLine("That's all folks! Press enter to close this window."); Console.ReadLine(); }
private static ICapabilities ConvertOptionsToCapabilities(EdgeOptions options) { if (options == null) { throw new ArgumentNullException("options", "options must not be null"); } return(options.ToCapabilities()); }
private static IWebDriver CreateEdgeWebDriver(bool silentMode) { try { var edgeService = Edge.EdgeDriverService.CreateDefaultService(); edgeService.HideCommandPromptWindow = true; var edgeOptions = new Edge.EdgeOptions { PageLoadStrategy = PageLoadStrategy.Eager, }; return(new Edge.EdgeDriver(edgeService, edgeOptions)); } catch (DriverServiceNotFoundException ex) { throw new DriverServiceNotFoundException("To install run the following in an command prompt with admin privileges:\nDISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0", ex); } }
public void SetupTest() { if (System.Environment.Is64BitOperatingSystem) { serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), serverPath); } else { serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles%"), serverPath); } EdgeOptions options = new EdgeOptions(); options.PageLoadStrategy = EdgePageLoadStrategy.Eager; this.driver = new EdgeDriver(serverPath, options); //Set page load timeout to 5 seconds this.driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(5)); }
private static ICapabilities ConvertOptionsToCapabilities(EdgeOptions options, bool serviceUsingChromium) { if (options == null) { throw new ArgumentNullException("options", "options must not be null"); } if (serviceUsingChromium != options.UseChromium) { if (serviceUsingChromium) { throw new WebDriverException("options.UseChromium must be set to true when using an Edge Chromium driver service."); } else { throw new WebDriverException("options.UseChromium must be set to false when using an Edge Legacy driver service."); } } return(options.ToCapabilities()); }
public DefaultEdgeDriver(EdgeDriverService service, EdgeOptions options) : base(service, options) { }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified <see cref="EdgeDriverService"/>. /// </summary> /// <param name="service">The <see cref="EdgeDriverService"/> to use.</param> /// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public EdgeDriver(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout) : base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options)) { System.Threading.Thread.Sleep(1000); }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified path /// to the directory containing EdgeDriver.exe, options, and command timeout. /// </summary> /// <param name="edgeDriverDirectory">The full path to the directory containing EdgeDriver.exe.</param> /// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public EdgeDriver(string edgeDriverDirectory, EdgeOptions options, TimeSpan commandTimeout) : this(EdgeDriverService.CreateDefaultService(edgeDriverDirectory), options, commandTimeout) { }
/// <summary> /// Creates a default instance of the EdgeDriverService using a specified path to the WebDriver executable with the given name and listening port. /// </summary> /// <param name="driverPath">The directory containing the WebDriver executable.</param> /// <param name="driverExecutableFileName">The name of the WebDriver executable file</param> /// <param name="port">The port number on which the driver will listen</param> /// <param name="options">An <see cref="EdgeOptions"/> object containing options for the service.</param> /// <returns>A EdgeDriverService using the specified port.</returns> public static EdgeDriverService CreateDefaultServiceFromOptions(string driverPath, string driverExecutableFileName, int port, EdgeOptions options) { return(new EdgeDriverService(driverPath, driverExecutableFileName, port, options.UseChromium)); }
/// <summary> /// Creates a default instance of the EdgeDriverService using a specified path to the WebDriver executable. /// </summary> /// <param name="driverPath">The directory containing the WebDriver executable.</param> /// <param name="options">An <see cref="EdgeOptions"/> object containing options for the service.</param> /// <returns>A EdgeDriverService using a random port.</returns> public static EdgeDriverService CreateDefaultServiceFromOptions(string driverPath, EdgeOptions options) { return(CreateDefaultServiceFromOptions(driverPath, EdgeDriverServiceFileName(options.UseChromium), options)); }
private static IWebDriver CreateNewWebDriver(string webBrowserName, BrowserType type, out IntPtr mainWindowHandle, string driversDirectory) { webBrowserName = webBrowserName.ToLower(); IWebDriver iWebDriver = null; List <Process> processesBeforeLaunch = GetProcesses(); string newProcessFilter = string.Empty; switch (type) { case BrowserType.Chrome: var chromeService = Chrome.ChromeDriverService.CreateDefaultService(driversDirectory); chromeService.HideCommandPromptWindow = true; var chromeOptions = new Chrome.ChromeOptions(); chromeOptions.PageLoadStrategy = PageLoadStrategy.None; chromeOptions.AddArgument("disable-infobars"); chromeOptions.AddArgument("--disable-bundled-ppapi-flash"); chromeOptions.AddArgument("--log-level=3"); chromeOptions.AddArgument("--silent"); chromeOptions.AddUserProfilePreference("credentials_enable_service", false); chromeOptions.AddUserProfilePreference("profile.password_manager_enabled", false); chromeOptions.AddUserProfilePreference("auto-open-devtools-for-tabs", false); //chromeOptions.AddAdditionalCapability("pageLoadStrategy", "none", true); iWebDriver = new Chrome.ChromeDriver(chromeService, chromeOptions); newProcessFilter = "chrome"; break; case BrowserType.Firefox: var firefoxService = Firefox.FirefoxDriverService.CreateDefaultService(driversDirectory); firefoxService.HideCommandPromptWindow = true; iWebDriver = new Firefox.FirefoxDriver(firefoxService); newProcessFilter = "firefox"; break; case BrowserType.InternetExplorer: IE.InternetExplorerDriverService ieService = IE.InternetExplorerDriverService.CreateDefaultService(driversDirectory); ieService.HideCommandPromptWindow = true; IE.InternetExplorerOptions options = new IE.InternetExplorerOptions() { IgnoreZoomLevel = true }; iWebDriver = new IE.InternetExplorerDriver(ieService, options); newProcessFilter = "iexplore"; break; case BrowserType.Edge: var edgeService = Edge.EdgeDriverService.CreateDefaultService(driversDirectory); edgeService.HideCommandPromptWindow = true; var edgeOptions = new Edge.EdgeOptions(); edgeOptions.PageLoadStrategy = PageLoadStrategy.Eager; iWebDriver = new Edge.EdgeDriver(edgeService, edgeOptions); newProcessFilter = "edge"; break; default: throw new ArgumentException($"Could not launch specified browser '{webBrowserName}'"); } var newProcess = GetNewlyCreatedProcesses(newProcessFilter, processesBeforeLaunch); mainWindowHandle = (newProcess != null) ? newProcess.MainWindowHandle : IntPtr.Zero; return(iWebDriver); }
public LegacyEdgeDriver(EdgeDriverService service, EdgeOptions options) : base(service, options) { }
public DevChannelEdgeDriver(EdgeDriverService service, EdgeOptions options) : base(service, options) { }
public ChromiumEdgeDriver(EdgeDriverService service, EdgeOptions options) : base(service, options) { }
public EdgeDriver(EdgeOptions options) : this(EdgeDriverService.CreateDefaultService(), options, RemoteWebDriver.DefaultCommandTimeout) { }
public EdgeDriver(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout) : base(new DriverServiceCommandExecutor(service, commandTimeout), EdgeDriver.ConvertOptionsToCapabilities(options)) { }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified <see cref="EdgeDriverService"/>. /// </summary> /// <param name="service">The <see cref="EdgeDriverService"/> to use.</param> /// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public EdgeDriver(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout) : base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options)) { }
/// <summary> /// Creates a default instance of the EdgeDriverService. /// </summary> /// <param name="options">An <see cref="EdgeOptions"/> object containing options for the service.</param> /// <returns>A EdgeDriverService that implements default settings.</returns> public static EdgeDriverService CreateDefaultServiceFromOptions(EdgeOptions options) { string serviceDirectory = DriverService.FindDriverServiceExecutable(EdgeDriverServiceFileName(options.UseChromium), MicrosoftWebDriverDownloadUrl); return(CreateDefaultServiceFromOptions(serviceDirectory, options)); }
/// <summary> /// Gets the web driver for locally installed browsers. /// </summary> /// <param name="testSettings">The test settings.</param> /// <param name="testOutputHelper">The test output helper.</param> /// <returns></returns> /// <exception cref="TestConfigurationException">The details you specified are invalid</exception> /// <exception cref="TestConfigurationException">The details you specified are invalid</exception> public static ITestWebDriver InitializeInstalledBrowserDriver(TestSettings testSettings, ITestOutputHelper testOutputHelper) { ScreenShotCounter = 0; TestOutputHelper = testOutputHelper; testSettings = ValidateSavePaths(testSettings); switch (testSettings.DriverType) { case WebDriverType.ChromeDriver: { string driverLocation = Path.Combine(AssemblyDirectory, "chromedriver.exe"); driverLocation = ValidateDriverPresentOrUnblocked(WebDriverType.ChromeDriver, driverLocation); testSettings.BrowserName = "Chrome"; var driverService = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverLocation), Path.GetFileName(driverLocation)); var options = new ChromeOptions { LeaveBrowserRunning = false }; options.AddArgument("--no-default-browser-check"); options.AddArgument("--test-type=browser"); options.AddArgument("--start-maximized"); options.AddArgument("--allow-no-sandbox-job"); options.AddArgument("--disable-component-update"); options.AddArgument("--auth-server-whitelist=" + testSettings.TestUri.Authority.Replace("www", "*")); var driver = new ChromeDriver(driverService, options, testSettings.TimeoutTimeSpan); var firingDriver = AttachDriverEvents(driver); if (testSettings.DeleteAllCookies) { firingDriver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { firingDriver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(firingDriver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } case WebDriverType.FirefoxDriver: { testSettings.BrowserName = "Firefox"; string winePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\Drivers\\FirefoxDrivers\\wires-0.6.2-win\\"; var driverService = FirefoxDriverService.CreateDefaultService(winePath); //var driverService = FirefoxDriverService.CreateDefaultService(); var options = new FirefoxOptions(); options.IsMarionette = true; var driver = new FirefoxDriver(driverService, options, testSettings.TimeoutTimeSpan); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } case WebDriverType.InternetExplorerDriver: { testSettings.BrowserName = "IE"; var driverName = "IEDriverServer.exe"; if (Environment.Is64BitProcess) { driverName = "IEDriverServer64.exe"; } string driverLocation = Path.Combine(AssemblyDirectory, driverName); driverLocation = ValidateDriverPresentOrUnblocked(WebDriverType.InternetExplorerDriver, driverLocation); var driverService = InternetExplorerDriverService.CreateDefaultService(Path.GetDirectoryName(driverLocation), Path.GetFileName(driverLocation)); var options = new InternetExplorerOptions { IgnoreZoomLevel = true, IntroduceInstabilityByIgnoringProtectedModeSettings = true, BrowserAttachTimeout = testSettings.TimeoutTimeSpan, RequireWindowFocus = true, ElementScrollBehavior = InternetExplorerElementScrollBehavior.Bottom, InitialBrowserUrl = testSettings.TestUri.AbsoluteUri, EnsureCleanSession = true, EnableNativeEvents = true }; var driver = new InternetExplorerDriver(driverService, options, testSettings.TimeoutTimeSpan); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } case WebDriverType.EdgeDriver: { string driverLocation = Path.Combine(AssemblyDirectory, "MicrosoftWebDriver.exe"); driverLocation = ValidateDriverPresentOrUnblocked(WebDriverType.EdgeDriver, driverLocation); testSettings.BrowserName = "Edge"; var driverService = EdgeDriverService.CreateDefaultService(Path.GetDirectoryName(driverLocation), Path.GetFileName(driverLocation)); var options = new EdgeOptions { PageLoadStrategy = EdgePageLoadStrategy.Default }; var driver = new EdgeDriver(driverService, options, testSettings.TimeoutTimeSpan); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } case WebDriverType.OperaDriver: { testSettings.BrowserName = "Opera"; var driverService = OperaDriverService.CreateDefaultService(); var options = new OperaOptions { LeaveBrowserRunning = false }; var driver = new OperaDriver(driverService, options, testSettings.TimeoutTimeSpan); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } case WebDriverType.SafariDriver: { testSettings.BrowserName = "Safari"; var options = new SafariOptions(); var driver = new SafariDriver(options); if (testSettings.DeleteAllCookies) { driver.Manage().Cookies.DeleteAllCookies(); } driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan); if (testSettings.MaximiseBrowser) { driver.Manage().Window.Maximize(); } var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper); TestWebDriver = extendedWebDriver; return extendedWebDriver; } } throw new TestConfigurationException("The details you specified are invalid"); }
/// <summary> /// Creates a default instance of the EdgeDriverService using a specified path to the WebDriver executable with the given name. /// </summary> /// <param name="driverPath">The directory containing the WebDriver executable.</param> /// <param name="driverExecutableFileName">The name of the WebDriver executable file.</param> /// <param name="options">An <see cref="EdgeOptions"/> object containing options for the service.</param> /// <returns>A EdgeDriverService using a random port.</returns> public static EdgeDriverService CreateDefaultServiceFromOptions(string driverPath, string driverExecutableFileName, EdgeOptions options) { return(CreateDefaultServiceFromOptions(driverPath, driverExecutableFileName, PortUtilities.FindFreePort(), options)); }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified options. /// </summary> /// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> public EdgeDriver(EdgeOptions options) : this(EdgeDriverService.CreateDefaultService(), options) { }
private static ICapabilities ConvertOptionsToCapabilities(EdgeOptions options) { if (options == null) { throw new ArgumentNullException("options", "options must not be null"); } return options.ToCapabilities(); }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified <see cref="EdgeDriverService"/>. /// </summary> /// <param name="service">The <see cref="EdgeDriverService"/> to use.</param> /// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public EdgeDriver(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout) : base(service, options, commandTimeout) { this.AddCustomEdgeCommands(); }
public SpecCompliantEdgeDriver(EdgeDriverService service, EdgeOptions options) : base(service, options) { }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified options. /// </summary> /// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> public EdgeDriver(EdgeOptions options) : this(EdgeDriverService.CreateDefaultService(), options, RemoteWebDriver.DefaultCommandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified <see cref="EdgeDriverService"/>. /// </summary> /// <param name="service">The <see cref="EdgeDriverService"/> to use.</param> /// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public EdgeDriver(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout) : base(service, options, commandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified path /// to the directory containing EdgeDriver.exe and options. /// </summary> /// <param name="edgeDriverDirectory">The full path to the directory containing EdgeDriver.exe.</param> /// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param> public EdgeDriver(string edgeDriverDirectory, EdgeOptions options) : this(edgeDriverDirectory, options, RemoteWebDriver.DefaultCommandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="EdgeDriver"/> class using the specified /// <see cref="EdgeDriverService"/> and options. /// </summary> /// <param name="service">The <see cref="EdgeDriverService"/> to use.</param> /// <param name="options">The <see cref="EdgeOptions"/> used to initialize the driver.</param> public EdgeDriver(EdgeDriverService service, EdgeOptions options) : this(service, options, RemoteWebDriver.DefaultCommandTimeout) { }