public override void GetStartService()
 {
     IEDriverService = InternetExplorerDriverService.CreateDefaultService();
     try
     {
         IEDriverService.Start();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
        IWebDriver IE()
        {
            InternetExplorerDriverService ieService = InternetExplorerDriverService.CreateDefaultService(AutomationTestConfig.WebDriverLocation);

            ieService.HideCommandPromptWindow = true;
            ieService.Start();

            var ieOptions = new InternetExplorerOptions();

            ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = false;

            return(new InternetExplorerDriver(ieService, ieOptions));
        }
Пример #3
0
        public static IWebDriver GetDriver(string BrowserName)
        {
            IWebDriver result = null;

            switch (BrowserName.ToLower())
            {
            case "chrome":
                ChromeDriverService cService = ChromeDriverService.CreateDefaultService();
                cService.Start();
                serviceId = cService.ProcessId;
                service   = cService;
                result    = new ThreadLocal <IWebDriver>(() => { return(new EventFiringWebDriver(new ChromeDriver())); }).Value;
                break;

            case "ie":
                InternetExplorerDriverService ieService = InternetExplorerDriverService.CreateDefaultService();
                ieService.Start();
                serviceId = ieService.ProcessId;
                service   = ieService;
                var options = new InternetExplorerOptions {
                    IgnoreZoomLevel = true
                };
                result = new ThreadLocal <IWebDriver>(() => { return(new EventFiringWebDriver(new InternetExplorerDriver(ieService, options))); }).Value;
                break;

            case "firefox":
                FirefoxDriverService ffService = FirefoxDriverService.CreateDefaultService();
                ffService.Start();
                serviceId = ffService.ProcessId;
                service   = ffService;
                result    = new ThreadLocal <IWebDriver>(() => { return(new EventFiringWebDriver(new FirefoxDriver(ffService))); }).Value;
                break;

            default:
                throw new Exception("Bad Driver Identifier: " + BrowserName + ".");
            }
            //result.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(60));
            result.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(60));
            result.Manage().Window.Maximize();

            wait   = new WebDriverWait(result, new TimeSpan(0, 0, 30));
            driver = result;
            return(result);
        }
Пример #4
0
        private static void Init(BrowserType type, string url, PlatformType platform, string dirverPath)
        {
            BrowserInfo         browserString = BrowserFinder.Find(type);
            DesiredCapabilities capabilities  = new DesiredCapabilities();

            switch (type)
            {
            case BrowserType.InternetExplorer:

                InternetExplorerOptions op = new InternetExplorerOptions();
                op.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                op.InitialBrowserUrl = url;
                op.AddAdditionalCapability("Platform", platform.ToString());

                InternetExplorerDriverService services = InternetExplorerDriverService.CreateDefaultService(dirverPath);
                services.Start();

                //webDriver = new InternetExplorerDriver(services, op);
                break;

            case BrowserType.Firefox:
                capabilities          = DesiredCapabilities.Firefox();
                capabilities.Platform = new Platform(platform);

                //webDriver = new RemoteWebDriver(capabilities);

                break;

            case BrowserType.Chrome:

                ChromeDriverService service = ChromeDriverService.CreateDefaultService(dirverPath);

                service.Start();

                ChromeOptions opts = new ChromeOptions();
                opts.AddAdditionalCapability("Platform", platform.ToString());

                //webDriver = new ChromeDriver(service, opts);
                break;

            case BrowserType.Android:
                //webDriver = new AndroidDriver();
                break;

            case BrowserType.Safari:
                SafariDriverServer server = new SafariDriverServer();
                server.Start();

                SafariDriverExtension ext = new SafariDriverExtension();
                ext.Install();

                SafariOptions opt = new SafariOptions();
                opt.AddAdditionalCapability("Platform", platform.ToString());

                capabilities          = DesiredCapabilities.Safari();
                capabilities.Platform = new Platform(platform);

                //webDriver = new SafariDriver(opt);

                break;

            default:
                capabilities          = DesiredCapabilities.Firefox();
                capabilities.Platform = new Platform(platform);
                //webDriver = new RemoteWebDriver(DesiredCapabilities.Firefox());
                break;
            }

            selenim = new WebDriverBackedSelenium(webDriver, url);
        }