Exemplo n.º 1
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.º 2
0
        public void SendKeysElementCombination(string actionRule)
        {
            // execute
            ExecuteAction <SendKeys>(MockBy.Positive(), actionRule);

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(true);
        }
Exemplo n.º 3
0
        public void KeyboardElementInvalidKeyName(string actionRule)
        {
            // execute
            ExecuteAction <Keyboard>(MockBy.Positive(), actionRule);

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(true);
        }
Exemplo n.º 4
0
        public void ContextClickElementRelativeNoElement(string actionRule)
        {
            // execute
            ExecuteAction <ContextClick>(MockBy.Positive(), actionRule);

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(true);
        }
Exemplo n.º 5
0
        public void AttributesException(string attribute)
        {
            // actual
            new MockWebDriver().FindElement(MockBy.Positive()).GetAttribute(attribute);

            // assertion
            Assert.IsTrue(false);
        }
        public void ExecuteScriptElementNoSemicolon(string actionRule)
        {
            // execute
            ExecuteAction <ExecuteScript>(MockBy.Positive(), actionRule);

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(true);
        }
Exemplo n.º 7
0
        public void SendKeysElementInterval(string actionRule)
        {
            // execute
            ExecuteAction <SendKeys>(MockBy.Positive(), actionRule);

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(Stopwatch.Elapsed.TotalMilliseconds > 1000);
        }
Exemplo n.º 8
0
        public void ClickElementFlat()
        {
            // execute
            ExecuteAction <Click>(MockBy.Positive());

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(true);
        }
Exemplo n.º 9
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.º 10
0
        public void ClickElementFlatNullElement(string actionRule)
        {
            // execute
            ExecuteAction <Click>(MockBy.Null(), actionRule);

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(true);
        }
Exemplo n.º 11
0
        public void ClickElementAbsolutePositive(string actionRule)
        {
            // execute
            ExecuteAction <Click>(MockBy.Positive(), actionRule);

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(true);
        }
        public void RegisterParameterElementText(string actionRule)
        {
            // execute
            ExecuteAction <RegisterParameter>(MockBy.Positive(), actionRule);

            // assertion
            Assert.AreEqual("Mock: Positive Element", $"{AutomationEnvironment.SessionParams["test-key"]}");
        }
Exemplo n.º 13
0
        public void DoubleClickElementFlatNull()
        {
            // execute
            ExecuteAction <DoubleClick>(MockBy.Null());

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(true);
        }
Exemplo n.º 14
0
        public void FileElement()
        {
            // generate element
            var onElement = MockWebElement.GetElement(new MockWebDriver(), MockBy.InputFile());

            // assertion
            Assert.IsTrue(onElement.TagName == "INPUT");
            Assert.IsTrue(onElement.GetAttribute("type") == "file");
        }
        public void RegisterParameterElementRegex(string actionRule)
        {
            // execute
            ExecuteAction <RegisterParameter>(MockBy.Positive(), actionRule);

            // assertion
            var actual = $"{AutomationEnvironment.SessionParams["test-key"]}";

            Assert.IsTrue(Regex.IsMatch(actual, "^\\d+$"));
        }
Exemplo n.º 16
0
        public void SendKeysElementAppiumInvalidState(string actionRule)
        {
            // set new mock driver for mobile device
            WebDriver = new MockAppiumDriver <IWebElement>();

            // execute
            ExecuteAction <SendKeys>(MockBy.Positive(), actionRule);

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(true);
        }
        public void GetScreenshotElementNone(string actionRule)
        {
            // execute
            var screenshot = ExecuteAction <GetScreenshot>(MockBy.None(), actionRule)
                             .ExtractionResults[0]
                             .Entities[0]
                             .EntityContentEntries["screenshot"];

            // assertion (no assertion here, expected is no exception)
            Assert.IsTrue(File.Exists($"{OutputDir}/image-b.png"));
            Assert.IsTrue(screenshot.Contains("image-b.png"));
        }
Exemplo n.º 18
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 RegisterParameterElementNullElement(string actionRule)
 {
     try
     {
         // execute
         ExecuteAction <RegisterParameter>(MockBy.Null(), actionRule);
     }
     catch (Exception)
     {
         // assertion
         var actual = $"{AutomationEnvironment.SessionParams["test-key"]}";
         Assert.AreEqual("//null", actual);
         throw;
     }
 }
 public void RegisterParameterElementNonElementText(string actionRule)
 {
     try
     {
         // execute
         ExecuteAction <RegisterParameter>(MockBy.Positive(), actionRule);
     }
     catch (Exception)
     {
         // assertion
         var actual = $"{AutomationEnvironment.SessionParams["test-key"]}";
         Assert.IsTrue(Regex.IsMatch(actual, "^\\d{4}-\\d{2}-\\d{2}$"));
         throw;
     }
 }
Exemplo n.º 21
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.º 22
0
        public void RandomNull() => Execute(attempts: 5, test: () =>
        {
            // setup
            var iterations = 0;

            // generate element
            var onElement = MockWebElement.GetElement(new MockWebDriver(), MockBy.Positive());

            // iterate
            while (onElement != null)
            {
                iterations++;
                onElement = MockWebElement.GetElement(new MockWebDriver(), MockBy.RandomNull());
            }

            // assertion
            Assert.IsTrue(iterations > 0);
        });
Exemplo n.º 23
0
        public void RandomStale() => Execute(attempts: 5, test: () =>
        {
            // setup
            var iterations = 0;

            // iterate
            while (iterations < 1)
            {
                try
                {
                    MockWebElement.GetElement(new MockWebDriver(), MockBy.RandomStale());
                }
                catch (Exception e) when(e is StaleElementReferenceException)
                {
                    iterations++;
                }
            }

            // assertion
            Assert.IsTrue(iterations > 0);
        });
 public void ExecuteScriptElementInvalidScript(string actionRule)
 {
     // execute
     ExecuteAction <ExecuteScript>(MockBy.Positive(), actionRule);
 }