Ejemplo n.º 1
0
            public static BrowserInfo Find(BrowserType type)
            {
                BrowserInfo info = new BrowserInfo();

                switch (type)
                {
                case BrowserType.InternetExplorer:

                    info.ExeName = "iexplore";

                    break;

                case BrowserType.Firefox:

                    info.ExeName = "firefox";

                    break;

                case BrowserType.Chrome:

                    info.ExeName = "googlechrome";

                    info.ExePath = @"C:\Program Files\Google\Chrome\Application\chrome.exe";

                    //TDO: Need to find the path from registry key
                    break;

                case BrowserType.Safari:
                    info.ExeName = "safari";
                    break;
                }

                return(info);
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to start the application with the specified type of browser, platform and URL
        /// </summary>
        public static void Start(BrowserType browserType, PlatformType platformType, string serverUrl, string driverPath, string applicationURL)
        {
            string browser = browserType.ToString().ToLower();
            DesiredCapabilities compat;

            switch (browserType)
            {
            case BrowserType.InternetExplorer:
                compat = DesiredCapabilities.InternetExplorer();
                break;

            case BrowserType.Chrome:
                compat = DesiredCapabilities.Chrome();
                break;

            case BrowserType.Safari:
                compat = DesiredCapabilities.Safari();
                break;

            case BrowserType.Firefox:
            default:
                compat = DesiredCapabilities.Firefox();
                break;
            }

            compat.IsJavaScriptEnabled = true;
            compat.Platform            = new Platform(platformType);
            webDriver = new ScreenShotRemoteWebDriver(compat);
            webDriver.Manage().Window.Maximize();
            webDriver.Url = applicationURL;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Method to start the application with the specified type of browser, platform and URL
        /// </summary>
        public static void Start()
        {
            BrowserType browser = BrowserType.Firefox;

            Enum.TryParse <BrowserType>(ConfigurationManager.AppSettings["BrowserType"], out browser);

            PlatformType ptype = PlatformType.Windows;

            Enum.TryParse <PlatformType>(ConfigurationManager.AppSettings["Platform"], out ptype);

            FrameworkBase.Log.LogMessage(string.Format("Starting {0} browser with platform as {1} & URL {2}....", browser.ToString(), ptype.ToString(), ConfigurationManager.AppSettings["ApplicationURL"]));
            //SeleniumHelper.Browser.Start(browser, ptype, ConfigurationManager.AppSettings["DriverDirectory"], ConfigurationManager.AppSettings["ApplicationURL"]);
            SeleniumHelper.Browser.Start(browser, ptype, "http://localhost:4444/wb/console", ConfigurationManager.AppSettings["DriverDirectory"], ConfigurationManager.AppSettings["ApplicationURL"]);
            FrameworkBase.Log.LogMessage("Browser is launched");
            FrameworkBase.Log.LogMessage("----------------------------------------------------------");
        }
Ejemplo n.º 4
0
        public static void Start(BrowserType btype, PlatformType ptype, string driverPath, string url)
        {
            selenim = new DefaultSelenium("localhost", 4444, btype.ToString(), url);

            Init(btype, url, ptype, driverPath);

            selenim.Start();

            selenim.WindowMaximize();

            webDriver.Manage().Window.Maximize();

            if (btype != BrowserType.Chrome && btype != BrowserType.Safari)
            {
                webDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(60000));
            }

            webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(60000));

            selenim.WaitForPageToLoad("120000");

            webDriver.Url = url;
            //selenim.Open(url);
        }
Ejemplo n.º 5
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);
        }