Exemplo n.º 1
0
        public static IWebDriver GetBrowserDriver()
        {
            if (driver != null)
            {
                return(driver);
            }

            var browser = WebUtilities.ConfigParamValReturn("Browser");


            if (!string.IsNullOrEmpty(browser))
            {
                switch (browser)
                {
                case "Firefox":

                    // driver = getFirefoxDriver();
                    break;

                case "IE":

                    driver = getIEDriver();
                    break;


                case "Chrome":

                    driver = getChromeDriver();
                    break;

                default:
                    //if there is no browser details is configured
                    Assert.Fail("Please add the configuration for " + browser + " in the BrowserManger");
                    break;
                }
            }
            //if no browser key value is provided in the app.config
            else
            {
                Assert.Fail("No browser input key is provided, please check and verify");
            }

            //driver.Manage().Timeouts().ImplicitlyWait = TimeSpan.FromSeconds(Constants.ImplicitWaitTime);
            //driver.Manage().Timeouts().SetPageLoadTimeout = TimeSpan.FromSeconds(Constants.PageLoadWaitTime);

            driver.Manage().Cookies.DeleteAllCookies();
            driver.Manage().Window.Maximize();
            return(driver);
        }