public void TimeoutMessageIncludesLastIgnoredException() { var ex = new NoSuchWindowException(""); var condition = GetCondition <object>(() => { throw ex; }); Expect.Once.On(mockClock).Method("LaterBy").With(TimeSpan.FromMilliseconds(0)).Will(Return.Value(startDate.Add(TimeSpan.FromSeconds(2)))); Expect.Once.On(mockClock).Method("IsNowBefore").With(startDate.Add(TimeSpan.FromSeconds(2))).Will(Return.Value(false)); IWait <IWebDriver> wait = new DefaultWait <IWebDriver>(mockDriver, mockClock); wait.Timeout = TimeSpan.FromMilliseconds(0); wait.PollingInterval = TimeSpan.FromSeconds(2); wait.IgnoreExceptionTypes(typeof(NoSuchWindowException)); var caughtException = Assert.Throws <WebDriverTimeoutException>(() => wait.Until(condition)); Assert.AreSame(ex, caughtException.InnerException); }
public void TimeoutMessageIncludesLastIgnoredException() { var ex = new NoSuchWindowException(""); var condition = GetCondition <object>(() => { throw ex; }); mockClock.Setup(_ => _.LaterBy(It.Is <TimeSpan>(x => x == TimeSpan.FromMilliseconds(0)))).Returns(startDate.Add(TimeSpan.FromSeconds(2))); mockClock.Setup(_ => _.IsNowBefore(It.Is <DateTime>(x => x == startDate.Add(TimeSpan.FromSeconds(2))))).Returns(false); IWait <IWebDriver> wait = new DefaultWait <IWebDriver>(mockDriver.Object, mockClock.Object); wait.Timeout = TimeSpan.FromMilliseconds(0); wait.PollingInterval = TimeSpan.FromSeconds(2); wait.IgnoreExceptionTypes(typeof(NoSuchWindowException)); var caughtException = Assert.Throws <WebDriverTimeoutException>(() => wait.Until(condition)); Assert.AreSame(ex, caughtException.InnerException); }
public void TimeoutMessageIncludesLastIgnoredException() { var ex = new NoSuchWindowException(""); var condition = GetCondition <object>(() => { throw ex; }); mockClock.Expects.One.Method(_ => _.LaterBy(TimeSpan.Zero)).With(TimeSpan.FromMilliseconds(0)).WillReturn(startDate.Add(TimeSpan.FromSeconds(2))); mockClock.Expects.One.Method(_ => _.IsNowBefore(DateTime.MinValue)).With(startDate.Add(TimeSpan.FromSeconds(2))).WillReturn(false); IWait <IWebDriver> wait = new DefaultWait <IWebDriver>(mockDriver.MockObject, mockClock.MockObject); wait.Timeout = TimeSpan.FromMilliseconds(0); wait.PollingInterval = TimeSpan.FromSeconds(2); wait.IgnoreExceptionTypes(typeof(NoSuchWindowException)); var caughtException = Assert.Throws <WebDriverTimeoutException>(() => wait.Until(condition)); Assert.AreSame(ex, caughtException.InnerException); }
public void PropagatesUnIgnoredExceptions() { var ex = new NoSuchWindowException(""); var condition = GetCondition <object>(() => { NonInlineableThrow(ex); return(null); }); Expect.Once.On(mockClock).Method("LaterBy").With(TimeSpan.FromMilliseconds(0)).Will(Return.Value(startDate.Add(TimeSpan.FromSeconds(2)))); Expect.Once.On(mockClock).Method("IsNowBefore").With(startDate.Add(TimeSpan.FromSeconds(2))).Will(Return.Value(true)); IWait <IWebDriver> wait = new DefaultWait <IWebDriver>(mockDriver, mockClock); wait.Timeout = TimeSpan.FromMilliseconds(0); wait.PollingInterval = TimeSpan.FromSeconds(2); wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(NoSuchFrameException)); var caughtException = Assert.Throws <NoSuchWindowException>(() => wait.Until(condition)); Assert.AreSame(ex, caughtException); // Regression test for issue #6343 StringAssert.Contains("NonInlineableThrow", caughtException.StackTrace, "the stack trace must include the call to NonInlineableThrow()"); }
public void PropagatesUnIgnoredExceptions() { var ex = new NoSuchWindowException(""); var condition = GetCondition <object>(() => { NonInlineableThrow(ex); return(null); }); mockClock.Setup(_ => _.LaterBy(It.Is <TimeSpan>(x => x == TimeSpan.FromMilliseconds(0)))).Returns(startDate.Add(TimeSpan.FromSeconds(2))); mockClock.Setup(_ => _.IsNowBefore(It.Is <DateTime>(x => x == startDate.Add(TimeSpan.FromSeconds(2))))).Returns(true); IWait <IWebDriver> wait = new DefaultWait <IWebDriver>(mockDriver.Object, mockClock.Object); wait.Timeout = TimeSpan.FromMilliseconds(0); wait.PollingInterval = TimeSpan.FromSeconds(2); wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(NoSuchFrameException)); var caughtException = Assert.Throws <NoSuchWindowException>(() => wait.Until(condition)); Assert.AreSame(ex, caughtException); // Regression test for issue #6343 StringAssert.Contains("NonInlineableThrow", caughtException.StackTrace, "the stack trace must include the call to NonInlineableThrow()"); }