Exemplo n.º 1
0
        public void ResizeBrowserWindowCustom()
        {
            var expectedWidth  = 1024;
            var expectedHeight = 768;

            Config.AddTestSettingValues(
                new Dictionary <string, string>
            {
                { "BrowserSize", $"{expectedWidth}x{expectedHeight}" }
            },
                "SeleniumMaqs",
                true);

            var driver = WebDriverFactory.GetDefaultBrowser();

            try
            {
                Assert.AreEqual(expectedWidth, driver.Manage().Window.Size.Width);
                Assert.AreEqual(expectedHeight, driver.Manage().Window.Size.Height);
            }
            finally
            {
                driver?.KillDriver();
            }
        }
Exemplo n.º 2
0
        public void SetTimeoutsGetWaitDriver()
        {
            IWebDriver driver    = null;
            IWebDriver newDriver = null;

            try
            {
                driver    = WebDriverFactory.GetDefaultBrowser();
                newDriver = WebDriverFactory.GetDefaultBrowser();
                SeleniumUtilities.SetTimeouts(driver);
                WebDriverWait wait = SeleniumConfig.GetWaitDriver(newDriver);
                Assert.AreEqual(wait.Timeout.TotalMilliseconds.ToString(), Config.GetValueForSection("SeleniumMaqs", "BrowserTimeout", "0"));
            }
            finally
            {
                try
                {
                    driver?.KillDriver();
                }
                finally
                {
                    newDriver?.KillDriver();
                }
            }
        }
Exemplo n.º 3
0
        public void OverridePageObjectWebdriver()
        {
            var oldWebDriver = this.basePageModel.GetWebDriver();

            this.basePageModel.OverrideWebDriver(WebDriverFactory.GetDefaultBrowser());

            Assert.AreNotEqual(oldWebDriver, this.basePageModel.GetWebDriver(), "The webdriver was not updated");
        }
Exemplo n.º 4
0
        public void GetBrowser()
        {
            IWebDriver driver = WebDriverFactory.GetDefaultBrowser();

            try
            {
                Assert.IsNotNull(driver);
            }
            finally
            {
                driver?.KillDriver();
            }
        }
Exemplo n.º 5
0
        public void OverridePageObjectWebdriver()
        {
            try
            {
                var oldWebDriver = this.getPageModel().GetWebDriver();
                this.getPageModel().OverrideWebDriver(WebDriverFactory.GetDefaultBrowser());

                Assert.AreNotEqual(oldWebDriver, this.getPageModel().GetWebDriver(), "The webdriver was not updated");
            }
            finally
            {
                this.getPageModel().GetWebDriver()?.KillDriver();
            }
        }
Exemplo n.º 6
0
        public void GetWaitDriver()
        {
            IWebDriver driver = WebDriverFactory.GetDefaultBrowser();

            try
            {
                WebDriverWait wait = SeleniumConfig.GetWaitDriver(driver);
                Assert.AreEqual(20, wait.Timeout.Seconds);
                Assert.AreEqual(1, wait.PollingInterval.Seconds);
            }
            finally
            {
                driver?.KillDriver();
            }
        }
Exemplo n.º 7
0
        public void SeleniumSetupNoneEventFiringTester()
        {
            // Take down the default driver
            this.WebDriver?.KillDriver();

            // This driver must manually be taken down
            var differentDriver = WebDriverFactory.GetDefaultBrowser();

            try
            {
                Assert.AreEqual(differentDriver.ToString(), Extend.GetLowLevelDriver(this.WebDriver).ToString());
            }
            finally
            {
                differentDriver?.KillDriver();
            }
        }
Exemplo n.º 8
0
        public void ResizeBrowserWindowDefault()
        {
            /*
             * Create driver at default size,
             * Set the driver window so that it is not at a default size
             * Create a new browser at default size and verify it is created at the default size and not changed size
             */
            Config.AddTestSettingValues(
                new Dictionary <string, string>
            {
                { "BrowserSize", "DEFAULT" }
            },
                "SeleniumMaqs");

            IWebDriver driverChangeSize = null;

            try
            {
                driverChangeSize = WebDriverFactory.GetDefaultBrowser();
                var defaultWidth    = driverChangeSize.Manage().Window.Size.Width;
                var defaultHidth    = driverChangeSize.Manage().Window.Size.Height;
                var nonDefaultWidth = defaultWidth + 1;
                var nonDefaultHidth = defaultHidth + 1;

                driverChangeSize.Manage().Window.Size = new System.Drawing.Size(nonDefaultWidth, nonDefaultHidth);

                IWebDriver driverDefault = null;

                try
                {
                    driverDefault = WebDriverFactory.GetDefaultBrowser();
                    Assert.AreEqual(defaultWidth, driverDefault.Manage().Window.Size.Width);
                    Assert.AreEqual(defaultHidth, driverDefault.Manage().Window.Size.Height);
                }
                finally
                {
                    driverDefault?.KillDriver();
                }
            }
            finally
            {
                driverChangeSize?.KillDriver();
            }
        }