/// <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;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified <see cref="SafariDriverService"/>.
 /// </summary>
 /// <param name="service">The <see cref="SafariDriverService"/> to use.</param>
 /// <param name="options">The <see cref="SafariOptions"/> to be used with the Safari driver.</param>
 /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
 public SafariDriver(SafariDriverService service, SafariOptions options, TimeSpan commandTimeout)
     : base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options))
 {
     this.AddCustomSafariCommand(AttachDebuggerCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/apple/attach_debugger");
     this.AddCustomSafariCommand(GetPermissionsCommand, HttpCommandInfo.GetCommand, "/session/{sessionId}/apple/permissions");
     this.AddCustomSafariCommand(SetPermissionsCommand, HttpCommandInfo.PostCommand, "/session/{sessionId}/apple/permissions");
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SafariDriverServer"/> class using the specified options.
        /// </summary>
        /// <param name="options">The <see cref="SafariOptions"/> defining the browser settings.</param>
        public SafariDriverServer(SafariOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options", "options must not be null");
            }

            int webSocketPort = options.Port;
            if (webSocketPort == 0)
            {
                webSocketPort = PortUtilities.FindFreePort();
            }

            this.webSocketServer = new WebSocketServer(webSocketPort, "ws://localhost/wd");
            this.webSocketServer.Opened += new EventHandler<ConnectionEventArgs>(this.ServerOpenedEventHandler);
            this.webSocketServer.Closed += new EventHandler<ConnectionEventArgs>(this.ServerClosedEventHandler);
            this.webSocketServer.StandardHttpRequestReceived += new EventHandler<StandardHttpRequestReceivedEventArgs>(this.ServerStandardHttpRequestReceivedEventHandler);
            this.serverUri = new Uri(string.Format(CultureInfo.InvariantCulture, "http://localhost:{0}/", webSocketPort.ToString(CultureInfo.InvariantCulture)));
            if (string.IsNullOrEmpty(options.SafariLocation))
            {
                this.safariExecutableLocation = GetDefaultSafariLocation();
            }
            else
            {
                this.safariExecutableLocation = options.SafariLocation;
            }
        }
        public RemoteWebDriver CreateDriver()
        {
            var options = new SafariOptions();
            chromeOptionsInitializer?.Invoke(options);

            return new SafariDriver(options);
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SafariDriverServer"/> class using the specified options.
        /// </summary>
        /// <param name="options">The <see cref="SafariOptions"/> defining the browser settings.</param>
        public SafariDriverServer(SafariOptions options)
        {
            int webSocketPort = options.Port;

            if (webSocketPort == 0)
            {
                webSocketPort = PortUtilities.FindFreePort();
            }

            this.webSocketServer         = new WebSocketServer(webSocketPort, "ws://localhost/wd");
            this.webSocketServer.Opened += new EventHandler <ConnectionEventArgs>(this.ServerOpenedEventHandler);
            this.webSocketServer.Closed += new EventHandler <ConnectionEventArgs>(this.ServerClosedEventHandler);
            this.webSocketServer.StandardHttpRequestReceived += new EventHandler <StandardHttpRequestReceivedEventArgs>(this.ServerStandardHttpRequestReceivedEventHandler);
            this.serverUri = new Uri(string.Format(CultureInfo.InvariantCulture, "http://localhost:{0}/", webSocketPort.ToString(CultureInfo.InvariantCulture)));
            if (string.IsNullOrEmpty(options.SafariLocation))
            {
                this.safariExecutableLocation = GetDefaultSafariLocation();
            }
            else
            {
                this.safariExecutableLocation = options.SafariLocation;
            }

            this.extension = new SafariDriverExtension(options.CustomExtensionPath, options.SkipExtensionInstallation);
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SafariDriverServer"/> class using the specified options.
        /// </summary>
        /// <param name="options">The <see cref="SafariOptions"/> defining the browser settings.</param>
        public SafariDriverServer(SafariOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options", "options must not be null");
            }

            int webSocketPort = options.Port;

            if (webSocketPort == 0)
            {
                webSocketPort = PortUtilities.FindFreePort();
            }

            this.webSocketServer         = new WebSocketServer(webSocketPort, "ws://localhost/wd");
            this.webSocketServer.Opened += new EventHandler <ConnectionEventArgs>(this.ServerOpenedEventHandler);
            this.webSocketServer.Closed += new EventHandler <ConnectionEventArgs>(this.ServerClosedEventHandler);
            this.webSocketServer.StandardHttpRequestReceived += new EventHandler <StandardHttpRequestReceivedEventArgs>(this.ServerStandardHttpRequestReceivedEventHandler);
            this.serverUri = new Uri(string.Format(CultureInfo.InvariantCulture, "http://localhost:{0}/", webSocketPort.ToString(CultureInfo.InvariantCulture)));
            if (string.IsNullOrEmpty(options.SafariLocation))
            {
                this.safariExecutableLocation = GetDefaultSafariLocation();
            }
            else
            {
                this.safariExecutableLocation = options.SafariLocation;
            }
        }
示例#7
0
        private static ICapabilities ConvertOptionsToCapabilities(SafariOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options", "options must not be null");
            }

            return(options.ToCapabilities());
        }
示例#8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SafariDriverCommandExecutor"/> class.
        /// </summary>
        /// <param name="options">The <see cref="SafariOptions"/> used to create the command executor.</param>
        public SafariDriverCommandExecutor(SafariOptions options)
        {
            this.server = new SafariDriverServer(options.Port);
            if (string.IsNullOrEmpty(options.SafariLocation))
            {
                this.safariExecutableLocation = GetDefaultSafariLocation();
            }
            else
            {
                this.safariExecutableLocation = options.SafariLocation;
            }

            this.extension = new SafariDriverExtension(options.CustomExtensionPath, options.SkipExtensionInstallation);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SafariDriverCommandExecutor"/> class.
        /// </summary>
        /// <param name="options">The <see cref="SafariOptions"/> used to create the command executor.</param>
        public SafariDriverCommandExecutor(SafariOptions options)
        {
            this.server = new SafariDriverServer(options.Port);
            if (string.IsNullOrEmpty(options.SafariLocation))
            {
                this.safariExecutableLocation = GetDefaultSafariLocation();
            }
            else
            {
                this.safariExecutableLocation = options.SafariLocation;
            }

            this.extension = new SafariDriverExtension(options.CustomExtensionPath, options.SkipExtensionInstallation);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SafariDriverServer"/> class using the specified options.
        /// </summary>
        /// <param name="options">The <see cref="SafariOptions"/> defining the browser settings.</param>
        public SafariDriverServer(SafariOptions options)
        {
            int webSocketPort = options.Port;
            if (webSocketPort == 0)
            {
                webSocketPort = PortUtilities.FindFreePort();
            }

            this.webSocketServer = new WebSocketServer(webSocketPort, "ws://localhost/wd");
            this.webSocketServer.Opened += new EventHandler<ConnectionEventArgs>(this.ServerOpenedEventHandler);
            this.webSocketServer.Closed += new EventHandler<ConnectionEventArgs>(this.ServerClosedEventHandler);
            this.webSocketServer.StandardHttpRequestReceived += new EventHandler<StandardHttpRequestReceivedEventArgs>(this.ServerStandardHttpRequestReceivedEventHandler);
            this.serverUri = new Uri(string.Format(CultureInfo.InvariantCulture, "http://localhost:{0}/", webSocketPort.ToString(CultureInfo.InvariantCulture)));
            if (string.IsNullOrEmpty(options.SafariLocation))
            {
                this.safariExecutableLocation = GetDefaultSafariLocation();
            }
            else
            {
                this.safariExecutableLocation = options.SafariLocation;
            }

            this.extension = new SafariDriverExtension(options.CustomExtensionPath, options.SkipExtensionInstallation);
        }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified path
 /// to the directory containing safaridriver and options.
 /// </summary>
 /// <param name="safariDriverDirectory">The full path to the directory containing SafariDriver executable.</param>
 /// <param name="options">The <see cref="SafariOptions"/> to be used with the Safari driver.</param>
 public SafariDriver(string safariDriverDirectory, SafariOptions options)
     : this(safariDriverDirectory, options, RemoteWebDriver.DefaultCommandTimeout)
 {
 }
        public IWebDriver StartSafariBrowser()
        {
            var options = new SafariOptions();

            // Add the WebDriver proxy capability.
            if (Config.Settings.httpProxy.startProxy)
            {
                var proxy = new OpenQA.Selenium.Proxy();
                proxy.HttpProxy = "localhost:" + TestBase.proxy.proxyPort;
                options.AddAdditionalCapability("proxy", proxy);
            }

            return new SafariDriver(options);
        }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified <see cref="SafariOptions"/>.
 /// </summary>
 /// <param name="options">The <see cref="SafariOptions"/> to use for this <see cref="SafariDriver"/> instance.</param>
 public SafariDriver(SafariOptions options)
     : base(new SafariDriverCommandExecutor(options), options.ToCapabilities())
 {
 }
 /// <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");
 }
示例#15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified <see cref="SafariDriverService"/>.
 /// </summary>
 /// <param name="service">The <see cref="SafariDriverService"/> to use.</param>
 /// <param name="options">The <see cref="SafariOptions"/> to be used with the Safari driver.</param>
 /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
 public SafariDriver(SafariDriverService service, SafariOptions options, TimeSpan commandTimeout)
     : base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options))
 {
 }
示例#16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified
 /// <see cref="SafariDriverService"/> and options.
 /// </summary>
 /// <param name="service">The <see cref="SafariDriverService"/> to use.</param>
 /// <param name="options">The <see cref="SafariOptions"/> used to initialize the driver.</param>
 public SafariDriver(SafariDriverService service, SafariOptions options)
     : this(service, options, RemoteWebDriver.DefaultCommandTimeout)
 {
 }
示例#17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified <see cref="SafariDriverService"/>.
 /// </summary>
 /// <param name="service">The <see cref="SafariDriverService"/> to use.</param>
 /// <param name="options">The <see cref="SafariOptions"/> to be used with the Safari driver.</param>
 /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
 public SafariDriver(SafariDriverService service, SafariOptions options, TimeSpan commandTimeout)
     : base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options))
 {
 }
示例#18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified path
 /// to the directory containing ChromeDriver.exe, options, and command timeout.
 /// </summary>
 /// <param name="safariDriverDirectory">The full path to the directory containing SafariDriver executable.</param>
 /// <param name="options">The <see cref="SafariOptions"/> to be used with the Safari driver.</param>
 /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
 public SafariDriver(string safariDriverDirectory, SafariOptions options, TimeSpan commandTimeout)
     : this(SafariDriverService.CreateDefaultService(safariDriverDirectory), options, commandTimeout)
 {
 }
示例#19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified path
 /// to the directory containing ChromeDriver.exe and options.
 /// </summary>
 /// <param name="safariDriverDirectory">The full path to the directory containing SafariDriver executable.</param>
 /// <param name="options">The <see cref="SafariOptions"/> to be used with the Safari driver.</param>
 public SafariDriver(string safariDriverDirectory, SafariOptions options)
     : this(safariDriverDirectory, options, RemoteWebDriver.DefaultCommandTimeout)
 {
 }
示例#20
0
 /// <summary>
 /// Returns an initialised Safari Web Driver.
 /// </summary>
 /// <remarks>You need to have Safari installed on the machine running the test</remarks>
 /// <param name="options">Profile to use for the driver</param>
 /// <returns>Initialised Safari driver</returns>
 public static SafariDriver Safari(SafariOptions options)
 {
     try
     {
         return new SafariDriver(options);
     }
     catch (Win32Exception e)
     {
         throw new BrowserNotFoundException("Safari", e);
     }
 }
示例#21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified path
 /// to the directory containing safaridriver, options, and command timeout.
 /// </summary>
 /// <param name="safariDriverDirectory">The full path to the directory containing SafariDriver executable.</param>
 /// <param name="options">The <see cref="SafariOptions"/> to be used with the Safari driver.</param>
 /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
 public SafariDriver(string safariDriverDirectory, SafariOptions options, TimeSpan commandTimeout)
     : this(SafariDriverService.CreateDefaultService(safariDriverDirectory), options, commandTimeout)
 {
 }
示例#22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified <see cref="SafariOptions"/>.
 /// </summary>
 /// <param name="options">The <see cref="SafariOptions"/> to use for this <see cref="SafariDriver"/> instance.</param>
 public SafariDriver(SafariOptions options)
     : this(SafariDriverService.CreateDefaultService(), options)
 {
 }
示例#23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified
 /// <see cref="SafariDriverService"/> and options.
 /// </summary>
 /// <param name="service">The <see cref="SafariDriverService"/> to use.</param>
 /// <param name="options">The <see cref="SafariOptions"/> used to initialize the driver.</param>
 public SafariDriver(SafariDriverService service, SafariOptions options)
     : this(service, options, RemoteWebDriver.DefaultCommandTimeout)
 {
 }
        public tstObject(int typNum, ref string profilePath, string baseURL)
        {
            brwsrType = typNum;

                switch (typNum)
                {
                    case 0:
                    {
                        SafariOptions opt1 = new SafariOptions();
                        opt1.CustomExtensionPath = Application.StartupPath + "\\SafariDriver2.32.0.safariextz";
                        opt1.SkipExtensionInstallation = false;

                        driver = new SafariDriver(opt1);
                        break;
                    }
                    case 1:
                    {
                        string runProfile = Application.StartupPath + "\\Firefox Profile";
                        string firebugPath = Application.StartupPath + "\\Firefox Profile\\firebug-1.9.2.xpi";
                        FirefoxProfile profile = new FirefoxProfile(runProfile);

                        //add firebug to the profile
                        //profile.AddExtension(firebugPath);

                        //add firePath to the profile
                        profile.AddExtension(firebugPath);

                        //set the webdriver_assume_untrusted_issuer to false
                        profile.SetPreference("webdriver_assume_untrusted_issuer", false);

                        //run the profile
                        driver = new FirefoxDriver(profile);

                        //maximize window
                        driver.Manage().Window.Maximize();

                        //Wait 4 seconds for an item to appear
                        driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
                        break;
                    }
                    //create a Chrome object
                    case 2:
                    {
                        var options = new ChromeOptions();

                        //set the startup options to start maximzed
                        options.AddArguments("start-maximized");

                        //start Chrome maximized
                        driver = new ChromeDriver(@Application.StartupPath, options);

                        //Wait 10 seconds for an item to appear
                        driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
                        break;
                    }

                    //create an IE object
                    case 3:
                    {
                        //var options = new InternetExplorerOptions();

                        //set the startup options to start maximzed
                        //options.ToCapabilities();

                        driver = new InternetExplorerDriver(@Application.StartupPath);

                        //maximize window
                        driver.Manage().Window.Maximize();

                        //Wait 4 seconds for an item to appear
                        driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));

                        break;
                    }
                }
        }
        private void SetWebDriverToSafari()
        {
            var settings = new SafariOptions
            {
                SafariLocation = "",
                SkipExtensionInstallation = true
            };

            _capabilities = DesiredCapabilities.Safari();
            SetAdditionalCapabilities();

            WebDriver = new ScreenShotRemoteWebDriver(new Uri(Localhost), _capabilities);
        }
示例#26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriverCommandExecutor"/> class.
 /// </summary>
 /// <param name="options">The <see cref="SafariOptions"/> used to create the command executor.</param>
 public SafariDriverCommandExecutor(SafariOptions options)
 {
     this.server = new SafariDriverServer(options);
 }
示例#27
0
        private static ICapabilities ConvertOptionsToCapabilities(SafariOptions 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="SafariDriverCommandExecutor"/> class.
 /// </summary>
 /// <param name="options">The <see cref="SafariOptions"/> used to create the command executor.</param>
 public SafariDriverCommandExecutor(SafariOptions options)
 {
     this.server = new SafariDriverServer(options);
 }
示例#29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified <see cref="SafariOptions"/>.
 /// </summary>
 /// <param name="options">The <see cref="SafariOptions"/> to use for this <see cref="SafariDriver"/> instance.</param>
 public SafariDriver(SafariOptions options)
     : base(new SafariDriverCommandExecutor(options), options.ToCapabilities())
 {
 }
示例#30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SafariDriver"/> class using the specified <see cref="SafariOptions"/>.
 /// </summary>
 /// <param name="options">The <see cref="SafariOptions"/> to use for this <see cref="SafariDriver"/> instance.</param>
 public SafariDriver(SafariOptions options)
     : this(SafariDriverService.CreateDefaultService(), options)
 {
 }