public void ThrowsIfAllLocatorsFail() { mockDriver.Setup(_ => _.FindElement(It.Is <By>(x => x.Equals(By.Name("notthisname"))))).Throws <NoSuchElementException>().Verifiable(); mockDriver.Setup(_ => _.FindElement(It.Is <By>(x => x.Equals(By.TagName("notthiseither"))))).Throws <NoSuchElementException>().Verifiable(); mockDriver.Setup(_ => _.FindElement(It.Is <By>(x => x.Equals(By.Id("stillnotthis"))))).Throws <NoSuchElementException>().Verifiable(); var page = new FailsToFallbackPage(); PageFactory.InitElements(mockDriver.Object, page); Assert.Throws(typeof(NoSuchElementException), page.formElement.Clear); }
public void ThrowsIfAllLocatorsFail() { Expect.Once.On(mockDriver).Method("FindElement").With(By.Name("notthisname")).Will(Throw.Exception(new NoSuchElementException())); Expect.Once.On(mockDriver).Method("FindElement").With(By.TagName("notthiseither")).Will(Throw.Exception(new NoSuchElementException())); Expect.Once.On(mockDriver).Method("FindElement").With(By.Id("stillnotthis")).Will(Throw.Exception(new NoSuchElementException())); var page = new FailsToFallbackPage(); PageFactory.InitElements(mockDriver, page); Assert.Throws(typeof(NoSuchElementException), page.formElement.Clear); }