예제 #1
0
        public WebDriver(string driverType, LoggerClass log)
        {
            _log = log;
            if (ConfigurationManager.AppSettings.Get("Grid") == "true")
            {
                DesiredCapabilities capabilities = new DesiredCapabilities();
                switch (driverType)
                {
                case "Firefox":
                    capabilities = DesiredCapabilities.Firefox();
                    capabilities.SetCapability(CapabilityType.BrowserName, "firefox");
                    _log.Log("Start Webdriver grid firefox");
                    break;

                case "IE":
                    capabilities = DesiredCapabilities.InternetExplorer();
                    capabilities.SetCapability(CapabilityType.BrowserName, "internet explorer");
                    _log.Log("Start Webdriver grid internet explorer");
                    break;

                case "Chrome":
                    capabilities = DesiredCapabilities.Chrome();
                    capabilities.SetCapability(CapabilityType.BrowserName, "chrome");
                    _log.Log("Start Webdriver grid chrome");
                    break;

                default:
                    capabilities = DesiredCapabilities.Chrome();
                    capabilities.SetCapability(CapabilityType.BrowserName, "chrome");
                    _log.Log("Start Webdriver grid default chrome");
                    break;
                }
                switch (ConfigurationManager.AppSettings.Get("PlatformType"))
                {
                case "Windows":
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
                    _log.Log("Platform grid Windows");
                    break;

                case "Linux":
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Linux));
                    _log.Log("Platform grid Linux");
                    break;

                case "Mac":
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Mac));
                    _log.Log("Platform grid Mac");
                    break;

                case "Unix":
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Unix));
                    _log.Log("Platform grid Unix");
                    break;

                case "XP":
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.XP));
                    _log.Log("Platform grid XP");
                    break;

                default:
                    capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
                    _log.Log("Platform grid default Windows");
                    break;
                }

                capabilities.SetCapability("marionette", true);
                Driver = new RemoteWebDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("localhost") + ":" + ConfigurationManager.AppSettings.Get("port") + "/wd/hub"), capabilities);
                _log.Log("Grid Server" + "http://" + ConfigurationManager.AppSettings.Get("localhost") + ":" + ConfigurationManager.AppSettings.Get("port") + "/wd/hub");
            }
            else
            {
                switch (driverType)
                {
                case "Firefox":
                    Driver = new FirefoxDriver();
                    _log.Log("Start firefox webdriver");
                    break;

                case "IE":
                    Driver = new InternetExplorerDriver();
                    _log.Log("Start internet explorer webdriver");
                    break;

                case "Chrome":
                    Driver = new ChromeDriver();
                    _log.Log("Start Chrome webdriver");
                    break;

                default:
                    Driver = new ChromeDriver();
                    _log.Log("Start default Chrome webdriver");
                    break;
                }
            }

            _wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(_waitTimeout));
            Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
        }
예제 #2
0
 public WebDriver(LoggerClass log)
 {
     Driver = new ChromeDriver();
     _wait  = new WebDriverWait(Driver, TimeSpan.FromSeconds(_waitTimeout));
     _log   = log;
 }