public void ShouldLoadAllElementsBelongingToGroup()
        {
            var pageObjectB = new PageObjectB();

            Assert.That(new ElementGroup("alpha").GetElements(pageObjectB), Is.EquivalentTo(new Dictionary <String, IWebElement>
            {
                {
                    "ElementA", pageObjectB.ElementA
                },
                {
                    "ElementB", pageObjectB.ElementB
                },
                {
                    "ElementD", pageObjectB.ElementD
                }
            }));

            Assert.That(new ElementGroup("beta").GetElements(pageObjectB), Is.EquivalentTo(new Dictionary <String, IWebElement>
            {
                {
                    "ElementA", pageObjectB.ElementA
                },
                {
                    "ElementE", pageObjectB.ElementE
                }
            }));
        }
Beispiel #2
0
        public void ShouldCreateCustomWebElementUsingSearchContextAndLocator()
        {
            IWebElement wrappedWebElement = _mockRepository.OneOf <IWebElement>();

            Mock <ISearchContext> contextMock = new Mock <ISearchContext>();

            contextMock
            .Setup(ctx => ctx.FindElement(It.IsAny <By>()))
            .Returns(wrappedWebElement)
            .Verifiable();

            PageObjectB pageObjectB = _pageObjectFactory.CreateWebElement <PageObjectB>(contextMock.Object, By.Id("any"));

            Assert.That(pageObjectB, Is.Not.Null);
            Assert.That(pageObjectB.WebElement, Is.Not.Null.And.InstanceOf <IWrapsElement>());
            Assert.That((pageObjectB.WebElement as IWrapsElement).WrappedElement, Is.EqualTo(wrappedWebElement));

            contextMock.Verify();
        }
        public void ShouldIncludeElementsFromMultipleGroups()
        {
            var pageObjectB = new PageObjectB();

            Assert.That(new ElementGroup("alpha", "beta").GetElements(pageObjectB), Is.EquivalentTo(new Dictionary <String, IWebElement>
            {
                {
                    "ElementA", pageObjectB.ElementA
                },
                {
                    "ElementB", pageObjectB.ElementB
                },
                {
                    "ElementD", pageObjectB.ElementD
                },
                {
                    "ElementE", pageObjectB.ElementE
                }
            }));
        }