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)); }
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>(); }
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()); }
private object DecorateWrappedWebElement(Type typeToDecorate, IElementLocator elementLocator, IEnumerable <By> bys) { var element = WebElementProxy.Create(elementLocator, bys); return(CreateAndPopulateWrapsElement(typeToDecorate, element)); }
private object DecorateWebElement(IElementLocator elementLocator, IEnumerable <By> bys) { return(WebElementProxy.Create(elementLocator, bys)); }