Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of this action tests.
        /// </summary>
        protected ActionTests()
        {
            // setup: web automation
            var configuration = new EngineConfiguration
            {
                ElementSearchingTimeout = 100,
                PageLoadTimeout         = 100
            };
            var authentication = new Authentication
            {
                UserName = "",
                Password = ""
            };

            WebAutomation = new WebAutomation
            {
                Authentication      = authentication,
                EngineConfiguration = configuration
            };

            // setup: web driver
            WebDriver = new MockWebDriver();

            // setup: timer
            Stopwatch = new Stopwatch();
        }
        public void GetEnabledElementPositive(string by)
        {
            // execute
            var onElement = new MockWebDriver().GetEnabledElement(By.Name(by), timeout);

            // assertion
            Assert.IsTrue(onElement != default);
        }
        public void GetSelectedElementsTimeout(string by)
        {
            // execute
            var onElements = new MockWebDriver().GetSelectedElements(By.Name(by), timeout);

            // assertion
            Assert.IsTrue(!onElements.Any());
        }
Exemplo n.º 4
0
        public void WhiteListSingle(string locator)
        {
            // setup
            var element = new MockWebDriver().FindElement(By.XPath(locator));

            // assertion
            Assert.IsTrue(element != null);
        }
        public void GetElementsPositive(string by)
        {
            // execute
            var onElements = new MockWebDriver().GetElements(By.Name(by), timeout);

            // assertion
            Assert.IsTrue(onElements.Any());
        }
Exemplo n.º 6
0
        public void BodyElement(string locator)
        {
            // setup
            var element = new MockWebDriver().FindElement(By.XPath(locator));

            // assertion
            Assert.IsTrue(element?.TagName == "BODY");
        }
Exemplo n.º 7
0
        public void Attributes(string attribute, string expected)
        {
            // actual
            var actual = new MockWebDriver().FindElement(MockBy.Positive()).GetAttribute(attribute);

            // assertion
            Assert.IsTrue(Regex.IsMatch(actual, expected));
        }
Exemplo n.º 8
0
        public void WhiteListMultiple(string locator)
        {
            // setup
            var elements = new MockWebDriver().FindElements(By.XPath(locator));

            // assertion
            Assert.IsTrue(elements.Count > 0);
        }
        public void GetSelectedElementsPositive(string by)
        {
            // execute
            var onElements = new MockWebDriver().GetSelectedElements(By.Name(by), timeout);

            // assertion
            Assert.IsTrue(onElements.Count() == 2);
        }
Exemplo n.º 10
0
        public void AttributesNull(string attribute, string expected)
        {
            // actual
            var actual = new MockWebDriver().FindElement(MockBy.Positive()).GetAttribute(attribute);

            // assertion
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 11
0
        public void OuterHtml(string script)
        {
            // setup
            var driver = new MockWebDriver();

            // setup
            var actual = driver.ExecuteScript(script).ToString();

            // assertion (expected exception)
            Assert.IsTrue(!string.IsNullOrEmpty(actual));
        }
        public void PageObjectFactoryTest1()
        {
            var driver = new MockWebDriver();

            pageObjectFactory = new PageObjectFactory(driver);
            var loadedModules = pageObjectFactory.GetImportedModules();

            Assert.IsTrue(loadedModules.Count == 2);
            Assert.IsInstanceOfType(loadedModules[0], typeof(ModuleA));
            Assert.IsInstanceOfType(loadedModules[1], typeof(ModuleB));
        }
Exemplo n.º 13
0
        public void ScriptElementPositive()
        {
            // setup
            var driver = new MockWebDriver();

            // execute
            driver.ExecuteScript("arguments[0].checked=false");

            // assert
            Assert.IsTrue(true);
        }
Exemplo n.º 14
0
        public void ScrollWindow(string script)
        {
            // setup
            var driver = new MockWebDriver();

            // execute
            driver.ExecuteScript(script);

            // assert
            Assert.IsTrue(driver.Manage().Window.Position.Y == 500);
            Assert.IsTrue(driver.Manage().Window.Position.X == 400);
        }
Exemplo n.º 15
0
        public void NewTab(string script)
        {
            // setup
            var driver   = new MockWebDriver();
            var expected = driver.WindowHandles.Count + 1;

            // execute
            driver.ExecuteScript(script);

            // assert
            Assert.AreEqual(expected, actual: driver.WindowHandles.Count);
        }
Exemplo n.º 16
0
        public void AttributesValue(string attribute, string expected)
        {
            // setup
            var element = new MockWebDriver().FindElement(MockBy.Positive());

            element.SendKeys(expected);

            // get actual
            var actual = element.GetAttribute(attribute);

            // assertion
            Assert.AreEqual(expected, actual);
        }
        public void PreparePageTest()
        {
            var driver = new MockWebDriver();

            pageObjectFactory = new PageObjectFactory(driver);

            var pageA = pageObjectFactory.PreparePage <IMockAPage>();
            var pageB = pageObjectFactory.PreparePage <IMockBPage>();
            var pageD = pageObjectFactory.PreparePage <IMockDPage>();

            Assert.IsNotNull(pageA);
            Assert.IsNotNull(pageB);
            Assert.IsNotNull(pageD);
        }
Exemplo n.º 18
0
        public void PageSourceSet()
        {
            // setup
            const string Html   = "<html></html>";
            var          driver = new MockWebDriver();

            // assertion
            Assert.AreNotEqual(notExpected: Html, actual: driver.PageSource);

            // execute
            driver.PageSource = Html;

            // assertion
            Assert.AreEqual(expected: Html, actual: driver.PageSource);
        }
        public void PageObjectFactoryTest2()
        {
            var driver            = new MockWebDriver();
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <IWebDriver>(driver);
            pageObjectFactory = new PageObjectFactory(
                services: serviceCollection,
                scanAssemblies: false,
                loadModules: true);
            var loadedModules = pageObjectFactory.GetImportedModules();

            Assert.IsTrue(loadedModules.Count == 2);
            Assert.IsInstanceOfType(loadedModules[0], typeof(ModuleA));
            Assert.IsInstanceOfType(loadedModules[1], typeof(ModuleB));
        }
Exemplo n.º 20
0
        public void ScrollElement(string script)
        {
            // setup
            var driver  = new MockWebDriver();
            var element = driver.FindElement(MockBy.Positive());

            // execute
            driver.ExecuteScript(script, element);

            // actuals
            var scrollTop  = (string)driver.ExecuteScript("return arguments[0].scrollTop;", element);
            var scrollLeft = (string)driver.ExecuteScript("return arguments[0].scrollLeft;", element);

            // assert
            Assert.IsTrue(scrollLeft == "400");
            Assert.IsTrue(scrollTop == "500");
        }
Exemplo n.º 21
0
        private void DoGoToUrl(string url, bool isProperty)
        {
            // setup
            var driver = new MockWebDriver();

            // navigate
            if (isProperty)
            {
                driver.Url = url;
            }
            else
            {
                driver.Navigate().GoToUrl(url);
            }

            // assertion
            Assert.AreEqual(expected: url, actual: driver.Url);
        }
Exemplo n.º 22
0
 /// <summary>
 /// Creates new instance of this MockAlert object.
 /// </summary>
 /// <param name="driver">Parent driver under which this alert exists.</param>
 public MockAlert(MockWebDriver driver)
 {
     this.driver = driver;
 }
 /// <summary>
 /// Applies a new set of capabilities into this <see cref="MockWebDriver"/> instance.
 /// </summary>
 /// <param name="driver">This <see cref="MockWebDriver"/> instance.</param>
 /// <param name="capabilities">Set of Key/Value pairs to apply on this <see cref="MockWebDriver"/> instance.</param>
 /// <returns></returns>
 public static MockWebDriver ApplyCapabilities(this MockWebDriver driver, IDictionary <string, object> capabilities)
 {
     return(new MockWebDriver(driver.DriverBinaries, capabilities));
 }