Beispiel #1
0
        public void InvocationTrows_Retry(Mock <IElementLocator> elementLocatorMock,
                                          Mock <IWebElement> webElementMock,
                                          ICollection <By> bys)
        {
            var counter = 0;

            elementLocatorMock.Setup(x => x.LocateElement(bys))
            .Returns(webElementMock.Object);
            webElementMock.Setup(x => x.Click())
            .Callback(() =>
            {
                if (++counter == 3)
                {
                    throw new StaleElementReferenceException();
                }
            });

            var proxy = WebElementProxy.Create(elementLocatorMock.Object, bys);

            proxy.Click();
            proxy.Click();

            elementLocatorMock.Verify(x => x.LocateElement(bys), Times.Once());

            //Thrid call will cause a StaleElementReferenceException
            proxy.Click();

            elementLocatorMock.Verify(x => x.LocateElement(bys), Times.Exactly(2));
        }
Beispiel #2
0
        public void InvocationTrows_Rethrows(Mock <IElementLocator> elementLocatorMock,
                                             Mock <IWebElement> webElementMock,
                                             ICollection <By> bys)
        {
            var counter = 0;

            elementLocatorMock.Setup(x => x.LocateElement(bys))
            .Returns(webElementMock.Object);
            webElementMock.Setup(x => x.Click())
            .Callback(() =>
            {
                if (++counter >= 3)
                {
                    throw new StaleElementReferenceException();
                }
            });

            var proxy = WebElementProxy.Create(elementLocatorMock.Object, bys);

            proxy.Click();
            proxy.Click();

            //Thrid (and higher) callcount will cause a StaleElementReferenceException
            Action action = () => proxy.Click();

            action.Should().Throw <StaleElementReferenceException>();
        }
Beispiel #3
0
        public void Caches(Mock <IElementLocator> elementLocatorMock,
                           ICollection <By> bys)
        {
            var proxy = WebElementProxy.Create(elementLocatorMock.Object, bys);

            proxy.Click();
            proxy.Click();
            proxy.Click();

            elementLocatorMock.Verify(x => x.LocateElement(bys), Times.Once());
        }
Beispiel #4
0
        private object DecorateWrappedWebElement(Type typeToDecorate, IElementLocator elementLocator, IEnumerable <By> bys)
        {
            var element = WebElementProxy.Create(elementLocator, bys);

            return(CreateAndPopulateWrapsElement(typeToDecorate, element));
        }
Beispiel #5
0
 private object DecorateWebElement(IElementLocator elementLocator, IEnumerable <By> bys)
 {
     return(WebElementProxy.Create(elementLocator, bys));
 }