public void ShouldCreateSizzleSelector(string rawSelector) { var sut = By.SizzleSelector(rawSelector); sut.Should().NotBeNull(); sut.RawSelector.Should().Be(rawSelector); }
public void ShouldThrowExceptionWhenSearchContextDoesNotWrapDriver(string rawSelector) { var element = new SearchContextBuilder().AsWebElement().Build(); var sut = By.SizzleSelector(rawSelector); ((Action)(() => sut.FindElement(element))).Should().Throw <InvalidCastException>(); }
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>(); }
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); }
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); }
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); }
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>(); }
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 ShouldThrowExceptionWhenCreatingSizzleSelectorWithWhiteSpaceOnlyValue() => ((Action)(() => By.SizzleSelector(" "))).Should().Throw <ArgumentException>().And.ParamName.Should().Be("selector");
public void ShouldThrowExceptionWhenCreatingSizzleSelectorWithNullValue() => ((Action)(() => By.SizzleSelector(null))).Should().Throw <ArgumentNullException>() .And.ParamName.Should().Be("selector");