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

            ((Action)(() => sut.FindElement(element))).Should().Throw <InvalidCastException>();
        }
コード例 #2
0
        public void ShouldCreateJQuerySelector(string rawSelector)
        {
            var sut = By.JQuerySelector(rawSelector);

            sut.Should().NotBeNull();
            sut.RawSelector.Should().Be(rawSelector);
        }
コード例 #3
0
        public void ShouldThrowExceptionWhenElementIsNotFoundWithJQuerySelector(string rawSelector)
        {
            var driver = new WebDriverBuilder().WithJQueryLoaded().WithNoElementLocatedByJQuery(rawSelector)
                         .Build();
            var sut = By.JQuerySelector(rawSelector);

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

            sut.Should().NotBeNull();
            sut.RawSelector.Should().Be(rawSelector);
            sut.Variable.Should().Be(variable);
        }
コード例 #5
0
        public void ShouldCreateJQuerySelectorWithContext(string contextRawSelector, string rawSelector)
        {
            var sut = By.JQuerySelector(rawSelector, By.JQuerySelector(contextRawSelector));

            sut.Should().NotBeNull();
            sut.RawSelector.Should().Be(rawSelector);
            sut.Context.RawSelector.Should().Be(contextRawSelector);
        }
コード例 #6
0
        public void ShouldReturnEmptyResultWhenNoElementsAreFoundWithJQuerySelector(string rawSelector)
        {
            var driver = new WebDriverBuilder().WithJQueryLoaded().WithNoElementLocatedByJQuery(rawSelector)
                         .Build();
            var selector = By.JQuerySelector(rawSelector);
            var sut      = selector.FindElements(driver);

            sut.Should().NotBeNull().And.HaveCount(0);
        }
コード例 #7
0
        public void ShouldFindElementsByJQuerySelector(string rawSelector)
        {
            var driver = new WebDriverBuilder().WithJQueryLoaded().WithElementsLocatedByJQuery(rawSelector)
                         .Build();
            var selector = By.JQuerySelector(rawSelector);
            var sut      = selector.FindElements(driver);

            sut.Should().NotBeNull().And.HaveCount(2);
        }
コード例 #8
0
        public void ShouldThrowExceptionWhenSearchContextIsNotWebElement(string rawSelector)
        {
            var driver = new WebDriverBuilder().WithJQueryLoaded().WithElementLocatedByJQuery(rawSelector)
                         .WithElementLocatedByJQuery($"body > {rawSelector}").WithPathToElement(rawSelector)
                         .Build();
            var element = new SearchContextBuilder().WithWrappedDriver(driver).Build();
            var sut     = By.JQuerySelector(rawSelector);

            ((Action)(() => sut.FindElement(element))).Should().Throw <NotSupportedException>();
        }
コード例 #9
0
        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 = By.JQuerySelector(rawSelector);
            var sut      = selector.FindElement(element);

            sut.Should().NotBeNull();
        }
コード例 #10
0
 public void ShouldThrowExceptionWhenCreatingJQuerySelectorWithWhiteSpaceOnlyVariableValue(string rawSelector) =>
 ((Action)(() => By.JQuerySelector(rawSelector, variable: " "))).Should().Throw <ArgumentException>()
 .And.ParamName.Should().Be("variable");
コード例 #11
0
 public void ShouldThrowExceptionWhenCreatingJQuerySelectorWithWhiteSpaceOnlyValue() =>
 ((Action)(() => By.JQuerySelector(" "))).Should().Throw <ArgumentException>().And.ParamName.Should().Be("selector");
コード例 #12
0
 public void ShouldThrowExceptionWhenCreatingJQuerySelectorWithNullValue() =>
 ((Action)(() => By.JQuerySelector(null))).Should().Throw <ArgumentNullException>()
 .And.ParamName.Should().Be("selector");