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

            optionElement.SetupGet(e => e.Text).Returns("Option 1");
            optionElement.Setup(e => e.GetAttribute("value")).Returns("0");

            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 IWebElement[] { optionElement.Object }).ToList().AsReadOnly());

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

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

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count);

            var option = result.First();

            Assert.AreEqual("0", option.Value);
            Assert.AreEqual("Option 1", option.Text);

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

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

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

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

            Assert.IsNull(result);
            element.VerifyAll();
        }