示例#1
0
        public void IsHiddenShouldReturnTrueWhenElementIsNotDisplayed()
        {
            ElementMock.Setup(e => e.Size).Returns(new Size(100, 100));
            ElementMock.Setup(e => e.Displayed).Returns(false);

            Assert.True(ElementMock.Object.IsHidden());
        }
示例#2
0
        public void IsHiddenShoutReturnFalseWhenElementIsDisplayed()
        {
            ElementMock.Setup(e => e.Size).Returns(new Size(100, 100));
            ElementMock.Setup(e => e.Displayed).Returns(true);

            Assert.That(ElementMock.Object.IsHidden(), Is.False);
        }
        public void ShouldReturnOnceElementBecameAddedToDocument(
            Func <IWebElement, TimeSpan, TimeSpan, String, IWebElement> waitForPresent,
            TimeSpan timeout, TimeSpan pollingInterval, String errorMessage
            )
        {
            ElementMock.Setup(e => e.Size).Throws <NoSuchElementException>();

            ExecuteAsync(() => ElementMock.Setup(e => e.Size).Returns(new Size(1, 1)), timeout.Subtract(TimeSpan.FromSeconds(2)));

            Assert.That(waitForPresent(ElementMock.Object, timeout, pollingInterval, errorMessage), Is.SameAs(ElementMock.Object));
        }
        public void ShouldHandleStaleElementReferenceException(
            Func <IWebElement, TimeSpan, TimeSpan, String, IWebElement> waitForPresent,
            TimeSpan timeout, TimeSpan pollingInterval, String errorMessage
            )
        {
            ElementMock.Setup(e => e.Size).Throws <StaleElementReferenceException>();

            ExecuteAsync(() => ElementMock.Setup(e => e.Size).Returns(new Size(1, 1)), TimeSpan.FromSeconds(2));

            Assert.That(waitForPresent(ElementMock.Object, timeout, pollingInterval, errorMessage), Is.SameAs(ElementMock.Object));
        }
        public void ShouldHandleStaleElementReferenceException(
            Action <IWebElement, TimeSpan, TimeSpan, string> waitUntilHidden,
            TimeSpan timeout, TimeSpan pollingInterval, string errorMessage
            )
        {
            ElementMock.Setup(e => e.Displayed).Throws <StaleElementReferenceException>();

            ExecuteAsync(() => ElementMock.Setup(e => e.Displayed).Returns(false), TimeSpan.FromSeconds(2));

            waitUntilHidden(ElementMock.Object, timeout, pollingInterval, errorMessage);
        }
        public void ShouldHandleNoSuchElementException(
            Action <IWebElement, TimeSpan, TimeSpan, String> waitUntilHidden,
            TimeSpan timeout, TimeSpan pollingInterval, String errorMessage
            )
        {
            ElementMock.Setup(e => e.Displayed).Returns(true);

            ExecuteAsync(() => ElementMock.Setup(e => e.Displayed).Throws <NoSuchElementException>(), TimeSpan.FromSeconds(2));

            waitUntilHidden(ElementMock.Object, timeout, pollingInterval, errorMessage);
        }
示例#7
0
        public void ShouldHandleNoSuchElementException(
            Func <IWebElement, TimeSpan, TimeSpan, String, IWebElement> waitForVisible,
            TimeSpan timeout, TimeSpan pollingInterval, String errorMessage
            )
        {
            ElementMock.Setup(e => e.Displayed).Throws <NoSuchElementException>();

            ExecuteAsync(() => ElementMock.Setup(e => e.Displayed).Returns(true), TimeSpan.FromSeconds(2));

            Assert.That(waitForVisible(ElementMock.Object, timeout, pollingInterval, errorMessage), Is.SameAs(ElementMock.Object));
        }
示例#8
0
        public void ShouldReturnOnceElementBecameVisible(
            Func <IWebElement, TimeSpan, TimeSpan, String, IWebElement> waitForVisible,
            TimeSpan timeout, TimeSpan pollingInterval, String errorMessage
            )
        {
            ElementMock.Setup(e => e.Displayed).Returns(false);

            ExecuteAsync(() => ElementMock.Setup(e => e.Displayed).Returns(true), timeout.Subtract(TimeSpan.FromSeconds(2)));

            Assert.That(waitForVisible(ElementMock.Object, timeout, pollingInterval, errorMessage), Is.SameAs(ElementMock.Object));
        }
示例#9
0
        public void ShouldThrowWebDriverTimeoutExceptionWithGivenMessage(
            Func <IWebElement, TimeSpan, TimeSpan, string, IWebElement> waitForPresent,
            TimeSpan timeout, TimeSpan pollingInterval, string errorMessage
            )
        {
            ElementMock.Setup(e => e.Size).Throws <NoSuchElementException>();

            Assert.That(
                () => waitForPresent(ElementMock.Object, timeout, pollingInterval, errorMessage),
                Throws.InstanceOf <WebDriverTimeoutException>().With.Message.Contains(errorMessage)
                );
        }
        public void ShouldThrowWebDriverTimeoutExceptionWithGivenMessage(
            Action <IWebElement, TimeSpan, TimeSpan, string> waitUntilHidden,
            TimeSpan timeout, TimeSpan pollingInterval, string errorMessage
            )
        {
            ElementMock.Setup(e => e.Displayed).Returns(true);

            Assert.That(
                () => waitUntilHidden(ElementMock.Object, timeout, pollingInterval, errorMessage),
                Throws.InstanceOf <WebDriverTimeoutException>().With.Message.Contains(errorMessage)
                );
        }
示例#11
0
        public void ShouldThrowWebDriverTimeoutExceptionWithGivenMessage(
            Func <IWebElement, TimeSpan, TimeSpan, String, IWebElement> waitForVisible,
            TimeSpan timeout, TimeSpan pollingInterval, String errorMessage
            )
        {
            ElementMock.Setup(e => e.Displayed).Returns(false);

            Assert.That(
                () => waitForVisible(ElementMock.Object, timeout, pollingInterval, errorMessage),
                Throws.InstanceOf <WebDriverTimeoutException>().With.Message.Contains(errorMessage)
                );
        }
        public void ShouldReturnOnceElementBecameHidden(
            Action <IWebElement, TimeSpan, TimeSpan, string> waitUntilHidden,
            TimeSpan timeout, TimeSpan pollingInterval, string errorMessage
            )
        {
            ElementMock.Setup(e => e.Displayed).Returns(true);

            ExecuteAsync(
                () => ElementMock.Setup(e => e.Displayed).Returns(false),
                timeout.Subtract(TimeSpan.FromSeconds(2))
                );

            waitUntilHidden(ElementMock.Object, timeout, pollingInterval, errorMessage);
        }
示例#13
0
        public void IsHiddenShouldYieldTrueWhenThereIsNoSuchElement()
        {
            ElementMock.Setup(e => e.Size).Throws <NoSuchElementException>();

            Assert.That(ElementMock.Object.IsHidden(), Is.True);
        }
示例#14
0
        public void IsPresentShouldYieldFalseWhenElementDoesNotExist()
        {
            ElementMock.Setup(e => e.Size).Throws <NoSuchElementException>();

            Assert.False(ElementMock.Object.IsPresent());
        }
示例#15
0
        public void IsPresentShouldYieldTrueWhenElementExist()
        {
            ElementMock.Setup(e => e.Size).Returns(new Size(100, 100));

            Assert.True(ElementMock.Object.IsPresent());
        }