Exemplo n.º 1
0
            public void When_index_is_between_0_and_2_Then_returns_webElement_at_matching_index(
                int index,
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value
                )
            {
                // Arrange
                var expected = webElements.ElementAt(index);

                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                var sut = new SearchProperty <IWebElement>(
                    locator,
                    value,
                    webDriver,
                    index,
                    150.Milliseconds());

                // Act
                var actual = sut.Find();

                // Assert
                actual.ShouldBe(expected);
            }
Exemplo n.º 2
0
            public void When_index_is_not_defined_Then_returns_first_WebElement(
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value)
            {
                // Arrange
                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                var sut = new SearchProperty <IWebElement>(locator, value, webDriver, 150.Milliseconds());

                // Act
                var actual = sut.Find();

                // Assert
                actual.ShouldBe(webElements.First());
            }
Exemplo n.º 3
0
            public void When_index_is_out_of_range_Then_throws_TimeoutException(
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value)
            {
                // Arrange
                var timeout         = 100.Milliseconds();
                int indexOutOfRange = webElements.Count + 1;

                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                var sut = new SearchProperty <IWebElement>(locator, value, webDriver, indexOutOfRange, 150.Milliseconds());

                // Assert
                Assert.Throws <TimeoutException>(() => sut.Find(timeout));
            }
Exemplo n.º 4
0
            public void When_index_is_out_of_range_Then_throws_OperationCanceledException(
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value)
            {
                // Arrange
                using var cancellationTokenSource = new CancellationTokenSource(50.Milliseconds());
                int indexOutOfRange   = webElements.Count + 1;
                var cancellationToken = cancellationTokenSource.Token;

                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                var sut = new SearchProperty <IWebElement>(locator, value, webDriver, indexOutOfRange, 100.Milliseconds());

                // Assert
                Assert.Throws <OperationCanceledException>(() => sut.Find(cancellationToken));
            }
Exemplo n.º 5
0
            public void When_try_to_find_Then_throws_OperationCanceledException(
                int index,
                IFindsByFluentSelector <IWebElement> webDriver,
                [Frozen] IReadOnlyCollection <IWebElement> webElements,
                string locator,
                string value
                )
            {
                // Arrange
                var expected = webElements.ElementAt(index);

                Mock.Get(webDriver).Setup(x => x.FindElements(locator, value)).Returns(webElements);
                var sut = new SearchProperty <IWebElement>(
                    locator,
                    value,
                    webDriver,
                    index,
                    TimeSpan.Zero);

                // Act, Assert
                Assert.Throws <OperationCanceledException>(() => sut.Find());
            }