コード例 #1
0
        public void ShouldCreateSizzleSelector(string rawSelector)
        {
            var sut = By.SizzleSelector(rawSelector);

            sut.Should().NotBeNull();
            sut.RawSelector.Should().Be(rawSelector);
        }
コード例 #2
0
        public void ShouldThrowExceptionWhenSearchContextDoesNotWrapDriver(string rawSelector)
        {
            var element = new SearchContextBuilder().AsWebElement().Build();
            var sut     = By.SizzleSelector(rawSelector);

            ((Action)(() => sut.FindElement(element))).Should().Throw <InvalidCastException>();
        }
コード例 #3
0
        public void ShouldThrowExceptionWhenElementIsNotFoundWithSizzleSelector(string rawSelector)
        {
            var driver = new WebDriverBuilder().WithSizzleLoaded().WithNoElementLocatedBySizzle(rawSelector)
                         .Build();
            var sut = By.SizzleSelector(rawSelector);

            ((Action)(() => sut.FindElement(driver))).Should().Throw <NoSuchElementException>();
        }
コード例 #4
0
        public void ShouldCreateSizzleSelectorWithContext(string contextRawSelector, string rawSelector)
        {
            var sut = By.SizzleSelector(rawSelector, By.SizzleSelector(contextRawSelector));

            sut.Should().NotBeNull();
            sut.RawSelector.Should().Be(rawSelector);
            sut.Context.RawSelector.Should().Be(contextRawSelector);
        }
コード例 #5
0
        public void ShouldReturnEmptyResultWhenNoElementsAreFoundWithSizzleSelector(string rawSelector)
        {
            var driver = new WebDriverBuilder().WithSizzleLoaded().WithNoElementLocatedBySizzle(rawSelector)
                         .Build();
            var sut    = By.SizzleSelector(rawSelector);
            var result = sut.FindElements(driver);

            result.Should().NotBeNull().And.HaveCount(0);
        }
コード例 #6
0
        public void ShouldFindElementsBySizzleSelector(string rawSelector)
        {
            var driver = new WebDriverBuilder().WithSizzleLoaded().WithElementsLocatedBySizzle(rawSelector)
                         .Build();
            var selector = By.SizzleSelector(rawSelector);
            var sut      = selector.FindElements(driver);

            sut.Should().NotBeNull().And.HaveCount(2);
        }
コード例 #7
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>();
        }
コード例 #8
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();
        }
コード例 #9
0
 public void ShouldThrowExceptionWhenCreatingSizzleSelectorWithWhiteSpaceOnlyValue() =>
 ((Action)(() => By.SizzleSelector(" "))).Should().Throw <ArgumentException>().And.ParamName.Should().Be("selector");
コード例 #10
0
 public void ShouldThrowExceptionWhenCreatingSizzleSelectorWithNullValue() =>
 ((Action)(() => By.SizzleSelector(null))).Should().Throw <ArgumentNullException>()
 .And.ParamName.Should().Be("selector");