コード例 #1
0
        public void ShouldThrowExceptionWhenSearchContextDoesNotWrapDriver(string rawSelector)
        {
            var element = new SearchContextBuilder().AsWebElement().Build();
            var sut     = By.SizzleSelector(rawSelector);

            ((Action)(() => sut.FindElement(element))).Should().Throw <InvalidCastException>();
        }
コード例 #2
0
        public void ShouldThrowExceptionWhenSearchContextIsNotWebElement(string rawSelector)
        {
            var driver = new WebDriverBuilder().WithSizzleLoaded().WithElementLocatedBySizzle(rawSelector)
                         .WithElementLocatedBySizzle($"body > {rawSelector}").WithPathToElement(rawSelector)
                         .Build();
            var element = new SearchContextBuilder().WithWrappedDriver(driver).Build();
            var sut     = By.SizzleSelector(rawSelector);

            ((Action)(() => sut.FindElement(element))).Should().Throw <NotSupportedException>();
        }
コード例 #3
0
        public void ShouldFindElementWithNestedSizzleSelector(string rawSelector)
        {
            var driver = new WebDriverBuilder().WithSizzleLoaded().WithElementLocatedBySizzle(rawSelector)
                         .WithElementLocatedBySizzle($"body > {rawSelector}").WithPathToElement(rawSelector)
                         .Build();
            var element = new SearchContextBuilder().AsWebElement().WithWrappedDriver(driver).Build();
            var sut     = By.SizzleSelector(rawSelector);
            var result  = sut.FindElement(element);

            result.Should().NotBeNull();
        }
        public void ShouldFindElementWithNestedJQuerySelector(string rawSelector)
        {
            var driver = new WebDriverBuilder().WithJQueryLoaded().WithElementLocatedByJQuery(rawSelector)
                         .WithElementLocatedByJQuery($"body > {rawSelector}").WithPathToElement(rawSelector)
                         .Build();
            var element  = new SearchContextBuilder().AsWebElement().WithWrappedDriver(driver).Build();
            var selector = JQuerySelector(rawSelector);
            var sut      = selector.FindElement(element);

            sut.Should().NotBeNull();
        }
コード例 #5
0
        public void ShouldThrowExceptionWhenSearchContextDoesNotWrapDriver(string rawSelector)
        {
            // Arrange
            var element = new SearchContextBuilder().ThatIsWebElement().Build();

            var selector = By.SizzleSelector(rawSelector);

            // Act
            Action action = () => selector.FindElement(element);

            // Assert
            action.ShouldThrow<NotSupportedException>();
        }
コード例 #6
0
        public void ShouldThrowExceptionWhenSearchContextIsNotWebElement(string rawSelector)
        {
            // Arrange
            var driver = new WebDriverBuilder().ThatHasSizzleLoaded().ThatContainsElementLocatedBySizzle(rawSelector)
                .ThatContainsElementLocatedBySizzle($"body > {rawSelector}").ThatCanResolvePathToElement(rawSelector)
                .Build();
            var element = new SearchContextBuilder().WithWrappedDriver(driver).Build();

            var selector = By.SizzleSelector(rawSelector);

            // Act
            Action action = () => selector.FindElement(element);

            // Assert
            action.ShouldThrow<NotSupportedException>();
        }
コード例 #7
0
        public void ShouldFindElementWithNestedSizzleSelector(string rawSelector)
        {
            // Arrange
            var driver = new WebDriverBuilder().ThatHasSizzleLoaded().ThatContainsElementLocatedBySizzle(rawSelector)
                .ThatContainsElementLocatedBySizzle($"body > {rawSelector}").ThatCanResolvePathToElement(rawSelector)
                .Build();
            var element = new SearchContextBuilder().WithWrappedDriver(driver).ThatIsWebElement().Build();

            var selector = By.SizzleSelector(rawSelector);

            // Act
            var result = selector.FindElement(element);

            // Assert
            result.Should().NotBeNull();
        }