Пример #1
0
        public void TestGetFillMethodForMultipleSelectControl()
        {
            var option = new Mock <IWebElement>(MockBehavior.Strict);

            option.SetupGet(o => o.Selected).Returns(false);
            this.SetupClick(option);

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

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

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

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

            element.Setup(e => e.FindElements(By.XPath(".//option[normalize-space(.) = \"Selected Item\"]")))
            .Returns(new ReadOnlyCollection <IWebElement>(new[] { option.Object }));

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

            var fillMethod = page.GetPageFillMethod(null);

            fillMethod(element.Object, "Selected Item");

            element.VerifyAll();
        }
Пример #2
0
        public void TestGetFillMethodForStandardControl()
        {
            var element = new Mock <IWebElement>(MockBehavior.Strict);

            element.SetupGet(e => e.TagName).Returns("div");
            element.Setup(e => e.SendKeys("Some Text"));

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

            var fillMethod = page.GetPageFillMethod(null);

            fillMethod(element.Object, "Some Text");

            element.VerifyAll();
        }
Пример #3
0
        public void TestGetFillMethodForRadioButtonControl()
        {
            var element = new Mock <IWebElement>(MockBehavior.Strict);

            element.SetupGet(e => e.TagName).Returns("input");
            element.Setup(e => e.GetAttribute("type")).Returns("radio");
            this.SetupClick(element);

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

            var fillMethod = page.GetPageFillMethod(null);

            fillMethod(element.Object, "true");

            element.Verify(e => e.Click(), Times.Exactly(2));
            element.VerifyAll();
        }
Пример #4
0
        public void TestGetFillMethodForCheckboxControl()
        {
            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(false);
            this.SetupClick(element);

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

            var fillMethod = page.GetPageFillMethod(null);

            fillMethod(element.Object, "true");

            element.VerifyAll();
        }
Пример #5
0
        public void TestGetFillMethodForMultipleSelectControl()
        {
            var option = new Mock<IWebElement>(MockBehavior.Strict);
            option.SetupGet(o => o.Selected).Returns(false);
            this.SetupClick(option);

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

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

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

            element.Setup(e => e.FindElements(By.XPath(".//option[normalize-space(.) = \"Selected Item\"]")))
                   .Returns(new ReadOnlyCollection<IWebElement>(new[] { option.Object }));

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

            var fillMethod = page.GetPageFillMethod(null);
            fillMethod(element.Object, "Selected Item");

            element.VerifyAll();
        }
Пример #6
0
        public void TestGetFillMethodForRadioButtonControl()
        {
            var element = new Mock<IWebElement>(MockBehavior.Strict);
            element.SetupGet(e => e.TagName).Returns("input");
            element.Setup(e => e.GetAttribute("type")).Returns("radio");
            this.SetupClick(element);

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

            var fillMethod = page.GetPageFillMethod(null);
            fillMethod(element.Object, "true");

            element.Verify(e => e.Click(), Times.Exactly(2));
            element.VerifyAll();
        }
Пример #7
0
        public void TestGetFillMethodForCheckboxControl()
        {
            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(false);
            this.SetupClick(element);

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

            var fillMethod = page.GetPageFillMethod(null);
            fillMethod(element.Object, "true");

            element.VerifyAll();
        }
Пример #8
0
        public void TestGetFillMethodForStandardInputControl()
        {
            var element = new Mock<IWebElement>(MockBehavior.Strict);
            element.SetupGet(e => e.TagName).Returns("input");
            element.Setup(e => e.GetAttribute("type")).Returns("text");
            element.Setup(e => e.SendKeys("Some Text"));

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

            var fillMethod = page.GetPageFillMethod(null);
            fillMethod(element.Object, "Some Text");

            element.VerifyAll();
        }