Exemplo n.º 1
0
        internal static IWebDriver CreateWebDriver(Browser browser, bool headless = false)
        {
            switch (browser)
            {
            case Browser.Chrome:
                _driver = CreateDefaultChromeDriver(headless);
                break;

            case Browser.Edge:
                _driver = new EdgeDriver();
                break;

            case Browser.InternetExplorer:
                _driver = new InternetExplorerDriver();
                break;

            case Browser.Remote:
                var options = new FirefoxOptions();
                options.PlatformName = "Linux";
                _driver = new RemoteWebDriver(RemoteUrl, options.ToCapabilities());
                break;

            default:
                throw new ArgumentException("Browser is not supported or valid!");
            }

            LogBrowserVersion(_driver);
            _driver.Manage().Cookies.DeleteAllCookies();
            return(_driver);
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            var options      = new FirefoxOptions();
            var capabilities = options.ToCapabilities() as DesiredCapabilities;

            driver = new RemoteWebDriver(new Uri("http://192.168.0.102:4444/wd/hub"), capabilities);
        }
Exemplo n.º 3
0
        private IWebDriver Launch(string url, BrowserType type = BrowserType.IE)
        {
            IWebDriver webdriver = null;

            switch (type)
            {
            case BrowserType.Chrome:

                ChromeOptions coptions = new ChromeOptions();

                coptions.ToCapabilities();
                webdriver = new ChromeDriver(coptions);
                break;

            case BrowserType.FireFox:

                FirefoxOptions foptions = new FirefoxOptions();

                foptions.ToCapabilities();
                webdriver = new FirefoxDriver(foptions);
                break;

            case BrowserType.IE:

                InternetExplorerOptions ieoptions = new InternetExplorerOptions();
                ieoptions.ToCapabilities();
                webdriver = new InternetExplorerDriver(ieoptions);

                break;
            }

            Thread.Sleep(4000);

            return(webdriver);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 初始化引擎
        /// </summary>
        /// <param name="option"></param>
        /// <returns></returns>
        private RemoteWebDriver LaunchFireFox(FirefoxOptions option)
        {
            // EngineType engineType = EngineType.Local;

            var engineType = _config.GetValue <EngineType>("Driver:Type");

            _logger.Info($"using driverType:{engineType}");

            var browserPath = engineType == EngineType.Embed ? GetBrowserPath() : "";

            //folder contain geckodriver
            var geckodriverFullPath = GetGeckoDriverPath();
            var pathArray           = geckodriverFullPath.Split(',');

            //use embed driver and geckodriver
            var fds = string.IsNullOrEmpty(geckodriverFullPath)
            ? FirefoxDriverService.CreateDefaultService()
            : FirefoxDriverService.CreateDefaultService(pathArray[0], pathArray[1]);

            if (!string.IsNullOrWhiteSpace(browserPath))
            {
                fds.FirefoxBinaryPath = browserPath;
            }


            var args = _config.GetSection("Driver:Argument").Get <List <string> >();

            //option.AddArgument("-headless");
            if (args != null && args.Count > 0)
            {
                option.AddArguments(args);
            }

            //hide add on or other log
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Environment.SetEnvironmentVariable("BROWSER_LOGFILE", "NUL 2>&1");
            }


            RemoteWebDriver driver = null;

            switch (engineType)
            {
            case EngineType.Local:
            case EngineType.Embed:
                driver = new FirefoxDriver(fds, option, TimeSpan.FromMinutes(1));
                break;

            case EngineType.Remote:
                //var uri = "http://10.252.90.122:4444/hub";
                var uri            = _config.GetValue <string>("Driver:EndPoint");
                var capabilities   = option.ToCapabilities();
                var commandTimeout = TimeSpan.FromSeconds(60);
                driver = new RemoteWebDriver(new Uri(uri), capabilities, commandTimeout);
                break;
            }

            return(driver);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            FirefoxProfile firefoxHeadlessProfile = new FirefoxProfile
            {
                DeleteAfterUse = true
            };

            firefoxHeadlessProfile.SetPreference("browser.cache.disk.enable", false);
            firefoxHeadlessProfile.SetPreference("browser.cache.memory.enable", false);
            firefoxHeadlessProfile.SetPreference("browser.cache.offline.enable", false);
            firefoxHeadlessProfile.SetPreference("network.http.use-cache", false);

            FirefoxOptions firefoxHeadlessOptions = new FirefoxOptions
            {
                Profile = firefoxHeadlessProfile
            };

            firefoxHeadlessOptions.AddArgument("--headless");

            DesiredCapabilities desiredCapabilities = (DesiredCapabilities)firefoxHeadlessOptions.ToCapabilities();

            desiredCapabilities.SetCapability("zal:idleTimeout", 300);
            desiredCapabilities.SetCapability("zal:tz", "America/Chicago");
            desiredCapabilities.SetCapability("zal:recordVideo", false);


            Uri gridUrl = new Uri("http://localhost:4444/wd/hub");

            IWebDriver driver = new RemoteWebDriver(gridUrl, desiredCapabilities)
            {
                Url = "http://www.google.com"
            };

            driver.Quit();
        }
Exemplo n.º 6
0
        public static IWebDriver CreateInstance(BrowserType browserType, string hubUrl)
        {
            IWebDriver driver   = null;
            TimeSpan   timeSpan = new TimeSpan(0, 3, 0);

            switch (browserType)
            {
            case BrowserType.Chrome:
                ChromeOptions chromeOptions = new ChromeOptions();
                driver = GetWebDriver(hubUrl, chromeOptions.ToCapabilities());
                break;

            case BrowserType.Edge:
                EdgeOptions options = new EdgeOptions();
                driver = GetWebDriver(hubUrl, options.ToCapabilities());
                break;

            case BrowserType.Firefox:
                FirefoxOptions firefoxOptions = new FirefoxOptions();
                driver = GetWebDriver(hubUrl, firefoxOptions.ToCapabilities());
                break;

            case BrowserType.Opera:
                OperaOptions operaOptions = new OperaOptions();
                driver = GetWebDriver(hubUrl, operaOptions.ToCapabilities());
                break;
            }

            return(driver);
        }
    public void SetUp()
    {
        var    Options = new FirefoxOptions();
        string GridURL = "http://localhost:4444/wd/hub";

        Driver = new RemoteWebDriver(new Uri(GridURL), Options.ToCapabilities());
    }
Exemplo n.º 8
0
        private static IWebDriver GetRemoteFireFoxDriver()
        {
            var options      = new FirefoxOptions();
            var capabilities = options.ToCapabilities();

            return(new RemoteWebDriver(new Uri("http://localhost:5566/wd/hub"), capabilities));
        }
Exemplo n.º 9
0
        public static IWebDriver GetRemoteFirefox()
        {
            FirefoxOptions firefoxOptions = new FirefoxOptions();

            firefoxOptions.SetPreference("intl.accept_languages", "pt-BR");

            return(new RemoteWebDriver(new Uri(seleniumHub), firefoxOptions.ToCapabilities()));
        }
Exemplo n.º 10
0
        internal static FirefoxOptions GetFirefoxOptions()
        {
            FirefoxOptions firefoxOptions = new FirefoxOptions();

            firefoxOptions.SetPreference(FirefoxDriver.ProfileCapabilityName, FirefoxConfiguration.GetFirefoxProfile().ToBase64String());
            firefoxOptions.ToCapabilities();
            firefoxOptions.LogLevel = FirefoxDriverLogLevel.Trace;
            return(firefoxOptions);
        }
        private void createWebdriver()
        {
            switch (configuration.environemnt)
            {
            case Environemnt.LOCAL:
                switch (configuration.browser)
                {
                case Browser.CHROME:
                    WebDriver = new ChromeDriver();
                    break;

                case Browser.FIREFOX:
                    WebDriver = new FirefoxDriver();
                    break;

                case Browser.EDGE:
                    WebDriver = new EdgeDriver();
                    break;
                }
                AddTimeouts();
                break;

            case Environemnt.REMOTE:
                switch (configuration.browser)
                {
                case Browser.CHROME:
                    ChromeOptions ChromeOption = new ChromeOptions();
                    ChromeOption.AcceptInsecureCertificates = false;
                    ChromeOption.AddArgument("--headless");
                    ChromeOption.AddArgument("--whitelisted-ips");
                    ChromeOption.AddArgument("--no-sandbox");
                    ChromeOption.AddArgument("--disable-extensions");
                    capabilities = ChromeOption.ToCapabilities();
                    break;

                case Browser.FIREFOX:
                    FirefoxOptions FirefoxOption = new FirefoxOptions();
                    capabilities = FirefoxOption.ToCapabilities();
                    break;

                case Browser.EDGE:
                    EdgeOptions EdgeOption = new EdgeOptions();
                    capabilities = EdgeOption.ToCapabilities();
                    break;

                default:
                    break;
                }
                WebDriver = new RemoteWebDriver(configuration.Hub, capabilities, TimeSpan.FromMinutes(5));    // NOTE: connection timeout of 600 seconds or more required for time to launch grid nodes if non are available.
                break;

            default:
                throw new Exception("Somethings gone wrong creating the WebDriver in DriverConfiguration");
            }
            AddTimeouts();
            DriverDevTools();
        }
Exemplo n.º 12
0
        internal static FirefoxOptions Options()
        {
            FirefoxOptions firefoxOptions = new FirefoxOptions();

            firefoxOptions.SetPreference(FirefoxDriver.ProfileCapabilityName, FireFoxDriverProfile.CreateProfile().ToBase64String());
            firefoxOptions.ToCapabilities();

            return(null);
        }
Exemplo n.º 13
0
        public void RemoteStartup()
        {
            FirefoxOptions options = new FirefoxOptions();

            options.AddArguments("disable-infobars");
            IDriver driver = new Driver(new Uri(G.SeleniumHubUrl), options.ToCapabilities());

            driver.GoToUrl("http://www.youtube.com");
        }
Exemplo n.º 14
0
        private IWebDriver GetRemoteBrowser(BrowserType browser, string version = null, DriverOptions options = null, LogLevel logLevel = LogLevel.Severe)
        {
            var gridAddress = new Uri($"{WebDriverSettings.SeleniumGridServer}/wd/hub");

            Log.Debug($"EXECUTING: GetRemoteBrowser(): {gridAddress.AbsoluteUri},{browser},{(!string.IsNullOrEmpty(version) ? version : string.Empty)},{(options != null ? options.GetType().Name : string.Empty)},{logLevel}");
            ICapabilities capabillities;

            SetupDriverOptions(browser, options, logLevel);

            switch (browser)
            {
            case BrowserType.Chrome:
                capabillities = _chromeOpts.ToCapabilities();
                break;

            case BrowserType.Edge:
                capabillities = _edgeOpts.ToCapabilities();
                break;

            case BrowserType.Firefox:
                capabillities = _firefoxOpts.ToCapabilities();
                break;

            case BrowserType.IE:
                _ieOpts.AddAdditionalCapability("version", !string.IsNullOrEmpty(version) ? version : "11");
                capabillities = _ieOpts.ToCapabilities();
                break;

            case BrowserType.Phantomjs:
                capabillities = _phantomJsOpts.ToCapabilities();
                break;

            case BrowserType.Safari:
                capabillities = _safariOpts.ToCapabilities();
                break;

            default:
                throw new Exception($"Unsupported BrowserType={browser}");
            }

            try
            {
                return(new RemoteWebDriver(gridAddress, capabillities));
            }

            catch (Exception e)
            {
                if (e is WebDriverTimeoutException || e is WebDriverException)
                {
                    var msg = $"Unable to connect to Selenium Grid: {gridAddress}, {e.Message}";
                    throw new Exception(msg, e);
                }

                throw new Exception($"An exception has occurred: {e.Message}", e);
            }
        }
Exemplo n.º 15
0
        public override IWebDriver CreateRemoteDriver()
        {
            var ops = new FirefoxOptions {
                Profile = CreateProfile()
            };

            ops.SetPreference("security.enterprise_roots.enabled", true);

            return(new RemoteWebDriver(GridUri, ops.ToCapabilities(), TimeSpan.FromSeconds(Timeouts.HttpCommandTimeout)));
        }
Exemplo n.º 16
0
        public void SetUp()
        {
            FirefoxOptions options = new FirefoxOptions
            {
                PlatformName = "Windows"
            };

            _driver = new RemoteWebDriver(new Uri("http://192.168.1.2:4444/wd/hub"), options.ToCapabilities(), TimeSpan.FromSeconds(10));
            _driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(10);
            _driver.Manage().Window.Maximize();
        }
Exemplo n.º 17
0
        private static object getFirefoxCapabilities_()
        {
            FirefoxOptions options = new FirefoxOptions();

            if (Utils.SeleniumUtils.RUN_HEADLESS)
            {
                options.AddArgument("--headless");
            }
            ICapabilities capabilities = options.ToCapabilities();

            return(capabilities);
        }
Exemplo n.º 18
0
        public void AbrirInstancia()
        {
            string navegador = ConfigurationManager.AppSettings["NavegadorDefault"].ToString();
            string nodeURL   = ConfigurationManager.AppSettings["IpHub"].ToString();
            string local     = ConfigurationManager.AppSettings["Local"].ToString();

            if (driver == null)
            {
                if (local.Equals("true"))
                {
                    ChromeOptions chrome = new ChromeOptions();
                    chrome.AddArgument("enable-automation");
                    chrome.AddArgument("--no-sandbox");
                    chrome.AddArgument("--disable-infobars");
                    chrome.AddArgument("--disable-dev-shm-usage");
                    chrome.AddArgument("--disable-browser-side-navigation");
                    chrome.AddArgument("--disable-gpu");
                    chrome.AddArgument("--window-size=1920,1080");
                    chrome.AddArgument("--lang=pt-BR");
                    chrome.PageLoadStrategy = PageLoadStrategy.Normal;
                    driver = new ChromeDriver(chrome);
                    //driver.Manage().Window.Maximize();
                }
                else
                {
                    switch (navegador)
                    {
                    case ("firefox"):
                        FirefoxOptions firefox = new FirefoxOptions();
                        driver = new RemoteWebDriver(new Uri(nodeURL), firefox.ToCapabilities());
                        driver.Manage().Window.Maximize();
                        break;

                    case ("chrome"):
                        ChromeOptions chrome = new ChromeOptions();
                        driver = new RemoteWebDriver(new Uri(nodeURL), chrome.ToCapabilities());
                        driver.Manage().Window.Maximize();
                        break;

                    case ("opera"):
                        OperaOptions opera = new OperaOptions();
                        opera.BinaryLocation = "@" + ConfigurationManager.AppSettings["PatchOperaExe"].ToString();;
                        driver = new RemoteWebDriver(new Uri(nodeURL), opera.ToCapabilities());
                        driver.Manage().Window.Maximize();
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
                driver.Navigate().GoToUrl(ConfigurationManager.AppSettings["URL"].ToString());
            }
        }
        RemoteWebDriver RemoteFirefoxBrowser(IApplicationSource applicationSource)
        {
            FirefoxOptions options = new FirefoxOptions();

            options.AddArguments(applicationSource.GetBrowserOptions());

            foreach (var capabilities in applicationSource.GetCapabilities())
            {
                options.AddAdditionalCapability(capabilities.Key, capabilities.Value, true);
            }
            return(new RemoteWebDriver(applicationSource.GetUri(), options.ToCapabilities(), TimeSpan.FromSeconds(180)));
        }
        private static FirefoxOptions GetFirefoxOptions()
        {
            var url = new Uri("http://10.6.122.49:5555/wd/hub");

            var options = new FirefoxOptions();

            options.SetPreference("webdriver.gecko.driver", pathFirefoxDriver);

            var driver = new RemoteWebDriver(url, options.ToCapabilities());

            return(options);
        }
Exemplo n.º 21
0
        private static IWebDriver CreateDesktopWebDriver()
        {
            DesiredCapabilities capabilities;

            var browser = Config.Settings.BrowserStackSettings.BsBrowser;

            switch (browser)
            {
            case "Chrome":
                var chromeOptions = new ChromeOptions();
                chromeOptions.AddArguments("--disable-popup-blocking");
                capabilities = chromeOptions.ToCapabilities() as DesiredCapabilities;
                SetCapabilities(capabilities, "Chrome");
                return(CreateRemoteWebDriver(capabilities));

            case "Firefox":
                FirefoxOptions firefoxOptions = new FirefoxOptions();
                capabilities = firefoxOptions.ToCapabilities() as DesiredCapabilities;
                SetCapabilities(capabilities, "Firefox");
                return(CreateRemoteWebDriver(capabilities));

            case "IE":
                InternetExplorerOptions ieOptions = new InternetExplorerOptions();
                capabilities = ieOptions.ToCapabilities() as DesiredCapabilities;
                capabilities.SetCapability("browserstack.ie.enablePopups", "true");
                SetCapabilities(capabilities, "IE");
                return(CreateRemoteWebDriver(capabilities));

            case "Edge":
                var edgeOptions = new EdgeOptions();
                edgeOptions.PageLoadStrategy = PageLoadStrategy.Eager;
                capabilities = edgeOptions.ToCapabilities() as DesiredCapabilities;
                SetCapabilities(capabilities, "Edge");
                return(CreateRemoteWebDriver(capabilities));

            case "Safari":
                SafariOptions safariOptions = new SafariOptions();
                capabilities = safariOptions.ToCapabilities() as DesiredCapabilities;
                capabilities.SetCapability("browserstack.safari.enablePopups", "true");
                SetCapabilities(capabilities, "Safari");
                return(CreateRemoteWebDriver(capabilities));

            case "Opera":
                OperaOptions operaOptions = new OperaOptions();
                capabilities = operaOptions.ToCapabilities() as DesiredCapabilities;
                SetCapabilities(capabilities, "Opera");
                return(CreateRemoteWebDriver(capabilities));

            default:
                throw new ArgumentOutOfRangeException("'Browser' value: " + browser);
            }
        }
Exemplo n.º 22
0
        public static void CreateInstance()
        {
            //criado um appconfig com a configuração desejada
            string navegador = ConfigurationManager.AppSettings["NavegadorDefault"].ToString();
            string local     = ConfigurationManager.AppSettings["Local"].ToString();
            string hubURL    = ConfigurationManager.AppSettings["Hublink"].ToString();

            if (INSTANCE == null)
            {
                switch (local)
                {
                case ("true"):     //Execução Local
                    ChromeOptions chromeOptions = new ChromeOptions();
                    INSTANCE = new ChromeDriver(chromeOptions);
                    INSTANCE.Manage().Window.Maximize();
                    break;

                case ("false"):     //Execução Grid
                    switch (navegador)
                    {
                    case ("firefox"):
                        FirefoxOptions firefox = new FirefoxOptions();
                        INSTANCE = new RemoteWebDriver(new Uri(hubURL), firefox.ToCapabilities());
                        INSTANCE.Manage().Window.Maximize();
                        break;

                    case ("chrome"):
                        ChromeOptions chrome = new ChromeOptions();
                        INSTANCE = new RemoteWebDriver(new Uri(hubURL), chrome.ToCapabilities());
                        INSTANCE.Manage().Window.Maximize();
                        break;

                    case ("opera"):
                        OperaOptions opera = new OperaOptions();
                        opera.BinaryLocation = "@" + ConfigurationManager.AppSettings["PathOperaExe"].ToString();
                        INSTANCE             = new RemoteWebDriver(new Uri(hubURL), opera.ToCapabilities());
                        INSTANCE.Manage().Window.Maximize();
                        break;

                    case ("edge"):
                        EdgeOptions edge = new EdgeOptions();
                        INSTANCE = new RemoteWebDriver(new Uri(hubURL), edge.ToCapabilities());
                        INSTANCE.Manage().Window.Maximize();
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                    break;
                }
            }
        }
Exemplo n.º 23
0
        public void SetUp()
        {
            var options = new FirefoxOptions();

            options.AddArguments("-devtools");

            driver = new FirefoxDriver(options);
            driver.Manage().Window.Maximize();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            Console.Out.Write(options.ToCapabilities());
        }
Exemplo n.º 24
0
        public void SetUp()
        {
            var options = new FirefoxOptions();

            options.AcceptInsecureCertificates = true;

            driver = new FirefoxDriver(options);
            driver.Manage().Window.Maximize();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            Console.Out.Write(options.ToCapabilities());
        }
Exemplo n.º 25
0
        public IWebDriver CreateWebDriver()
        {
            var browser = Config.Settings.RuntimeSettings.SeleniumBrowser;

            switch (browser)
            {
            case BrowserType.Chrome:
                var chromeOptions = new ChromeOptions();
                chromeOptions.AddArgument("--lang=" + Config.Settings.RuntimeSettings.BrowserLanguage);
                chromeOptions.AddArgument("--start-maximized");
                chromeOptions.AddArguments("--disable-popup-blocking");
                return(CreateRemoteWebDriver(chromeOptions.ToCapabilities()));

            case BrowserType.Firefox:
                var firefoxProfile = new FirefoxProfile();
                var firefoxOptions = new FirefoxOptions();
                firefoxProfile.SetPreference("intl.accept_languages", Config.Settings.RuntimeSettings.BrowserLanguage);
                firefoxProfile.ToBase64String();
                firefoxOptions.Profile = firefoxProfile;
                return(CreateRemoteWebDriver(firefoxOptions.ToCapabilities()));

            case BrowserType.Ie:
                var ieOptions = new InternetExplorerOptions()
                {
                    IgnoreZoomLevel          = true,
                    EnableNativeEvents       = false,
                    EnableFullPageScreenshot = true
                };

                ieOptions.AddAdditionalCapability("disable-popup-blocking", true);

                var browserVersion = Config.Settings.RuntimeSettings.BrowserVersion;
                if (browserVersion != null)
                {
                    ieOptions.AddAdditionalCapability(CapabilityType.Version, int.Parse(browserVersion), true);


                    return(CreateRemoteWebDriver(ieOptions.ToCapabilities()));
                }
                return(CreateRemoteWebDriver(ieOptions.ToCapabilities()));

            case BrowserType.Safari:
                throw new NotImplementedException("Remote WebDriver Safari is not implemented");

            case BrowserType.Edge:
                throw new NotImplementedException("Remote WebDriver Edge is not implemented");

            default:
                throw new InvalidEnumArgumentException($"Invalid BrowserType specified {browser}.");
            }
        }
Exemplo n.º 26
0
        private void init_driver_ff()
        {
            FirefoxOptions Options = new FirefoxOptions();

            //options.AddAdditionalCapability("browserName","firefox");
            //options.AddAdditionalCapability("platform", "WIN8_1");
            //options.AddAdditionalCapability("version", "ANY");
            // var caps = new FirefoxOptions().ToCapabilities();

            //var commandTimeOut = TimeSpan.FromMinutes(5);
            //driver = new RemoteWebDriver(new Uri(uri), options.ToCapabilities(), commandTimeOut);

            driver = new RemoteWebDriver(new Uri(uri), Options.ToCapabilities(), TimeSpan.FromSeconds(600));
        }
Exemplo n.º 27
0
        public void SetUp()
        {
            var options = new FirefoxOptions();

            options.UseLegacyImplementation   = true;
            options.BrowserExecutableLocation = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
            driver = new FirefoxDriver(options);

            driver.Manage().Window.Maximize();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            Console.Out.Write(options.ToCapabilities());
        }
Exemplo n.º 28
0
        private IWebDriver GetGridFirefox() //throws MalformedURLException
        {
            FirefoxOptions options = new FirefoxOptions();

            options.AddAdditionalCapability("ignoreProtectedModeSettings", true);
            options.AddAdditionalCapability("EnsureCleanSession", true);
            IWebDriver _webdriver = new RemoteWebDriver(new Uri(_HUB_URI), options.ToCapabilities(), TimeSpan.FromSeconds(300));

            return(_webdriver);

            //TAK W JAVA
            //DesiredCapabilities dc = DesiredCapabilities.Firefox();
            //IWebDriver driver = new RemoteWebDriver(new URL(_HUB_URI), dc);
            //return driver;
        }
Exemplo n.º 29
0
        public void GoogleTest()
        {
            FirefoxOptions options            = new FirefoxOptions();
            var            remoteWebDriverUrl = TestContext.Properties["remoteWebDriverUrl"] as string;

            _driver = new RemoteWebDriver(new Uri(remoteWebDriverUrl), options.ToCapabilities(), TimeSpan.FromMinutes(3));

            _driver.Navigate().GoToUrl("http://www.google.com");
            _driver.FindElement(By.Name("q")).SendKeys("Selenium");
            System.Threading.Thread.Sleep(5000);
            _driver.FindElement(By.Name("btnK")).Click();
            Assert.IsTrue(_driver.PageSource.Contains("Selenium"));
            //Assert.That(_driver.PageSource.Contains("Selenium"), Is.EqualTo(true),
            //                                "The text selenium doest not exist");
        }
        public void FirefoxDriverTest()
        {
            var options = new FirefoxOptions();

            options.AddAdditionalCapability("username", sauceUserName, true);
            options.AddAdditionalCapability("accessKey", sauceAccessKey, true);
            options.AddAdditionalCapability(CapabilityType.Platform, "Windows", true);

            using (var driver = new RemoteWebDriver(RemoteAddress, options.ToCapabilities(), CommandTimeout))
            {
                //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
                //driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(30);
                driver.Navigate().GoToUrl("https://login.live.com");
            }
        }