예제 #1
0
        public void TestGetElementTextWhenControlIsNotSpecialReturnsTheElementText()
        {
            var element = new Mock <IWebElement>(MockBehavior.Strict);

            element.SetupGet(e => e.TagName).Returns("DIV");
            element.SetupGet(e => e.Text).Returns("Normal Text");

            var nativePage = new NativePage();
            var page       = new SeleniumPage(nativePage, null);

            var result = page.GetElementText(element.Object);

            Assert.AreEqual("Normal Text", result);
            element.VerifyAll();
        }
예제 #2
0
        public void TestGetElementTextWhenControlIsCheckBoxInputControl()
        {
            var element = new Mock <IWebElement>(MockBehavior.Strict);

            element.SetupGet(e => e.TagName).Returns("input ");
            element.Setup(e => e.GetAttribute("type")).Returns("checkBox");
            element.SetupGet(e => e.Selected).Returns(true);

            var nativePage = new NativePage();
            var page       = new SeleniumPage(nativePage, null);

            var result = page.GetElementText(element.Object);

            Assert.AreEqual("True", result);
            element.VerifyAll();
        }
예제 #3
0
        public void TestGetElementTextWhenControlIsTextAreaControl()
        {
            var element = new Mock <IWebElement>(MockBehavior.Strict);

            element.SetupGet(e => e.TagName).Returns("textarea");
            element.Setup(e => e.GetAttribute("type")).Returns("textarea");
            element.Setup(e => e.GetAttribute("value")).Returns("Input Text Area");

            var nativePage = new NativePage();
            var page       = new SeleniumPage(nativePage, null);

            var result = page.GetElementText(element.Object);

            Assert.AreEqual("Input Text Area", result);
            element.VerifyAll();
        }
예제 #4
0
        public void TestGetElementTextWhenControlASelectControlReturnsTheSelectedItemText()
        {
            var option = new Mock <IWebElement>(MockBehavior.Strict);

            option.SetupGet(o => o.Selected).Returns(true);
            option.SetupGet(o => o.Text).Returns("Selected Item");

            var element = new Mock <IWebElement>(MockBehavior.Strict);

            element.SetupGet(e => e.TagName).Returns("select");

            element.Setup(e => e.GetAttribute("multiple")).Returns("false");

            element.Setup(e => e.FindElements(By.TagName("option")))
            .Returns(new ReadOnlyCollection <IWebElement>(new[] { option.Object }));

            var nativePage = new NativePage();
            var page       = new SeleniumPage(nativePage, null);

            var result = page.GetElementText(element.Object);

            Assert.AreEqual("Selected Item", result);
            element.VerifyAll();
        }
예제 #5
0
        public void TestGetElementTextWhenControlIsCheckBoxInputControl()
        {
            var element = new Mock<IWebElement>(MockBehavior.Strict);
            element.SetupGet(e => e.TagName).Returns("input ");
            element.Setup(e => e.GetAttribute("type")).Returns("checkBox");
            element.SetupGet(e => e.Selected).Returns(true);

            var nativePage = new NativePage();
            var page = new SeleniumPage(nativePage);

            var result = page.GetElementText(element.Object);

            Assert.AreEqual("True", result);
            element.VerifyAll();
        }
예제 #6
0
        public void TestGetElementTextWhenControlIsTextAreaControl()
        {
            var element = new Mock<IWebElement>(MockBehavior.Strict);
            element.SetupGet(e => e.TagName).Returns("textarea");
            element.Setup(e => e.GetAttribute("type")).Returns("textarea");
            element.Setup(e => e.GetAttribute("value")).Returns("Input Text Area");

            var nativePage = new NativePage();
            var page = new SeleniumPage(nativePage);

            var result = page.GetElementText(element.Object);

            Assert.AreEqual("Input Text Area", result);
            element.VerifyAll();
        }
예제 #7
0
        public void TestGetElementTextWhenControlASelectControlReturnsTheSelectedItemText()
        {
            var option = new Mock<IWebElement>(MockBehavior.Strict);
            option.SetupGet(o => o.Selected).Returns(true);
            option.SetupGet(o => o.Text).Returns("Selected Item");

            var element = new Mock<IWebElement>(MockBehavior.Strict);
            element.SetupGet(e => e.TagName).Returns("select");

            element.Setup(e => e.GetAttribute("multiple")).Returns("false");

            element.Setup(e => e.FindElements(By.TagName("option")))
                   .Returns(new ReadOnlyCollection<IWebElement>(new[] { option.Object }));

            var nativePage = new NativePage();
            var page = new SeleniumPage(nativePage);

            var result = page.GetElementText(element.Object);

            Assert.AreEqual("Selected Item", result);
            element.VerifyAll();
        }
예제 #8
0
        public void TestGetElementTextWhenControlIsNotSpecialReturnsTheElementText()
        {
            var element = new Mock<IWebElement>(MockBehavior.Strict);
            element.SetupGet(e => e.TagName).Returns("DIV");
            element.SetupGet(e => e.Text).Returns("Normal Text");

            var nativePage = new NativePage();
            var page = new SeleniumPage(nativePage);

            var result = page.GetElementText(element.Object);

            Assert.AreEqual("Normal Text", result);
            element.VerifyAll();
        }