public SeleniumQueryObject filterPredicate(SeleniumQueryObject seleniumQueryObject, Predicate<WebElement> filterFunction) { return new FilterPredicateFunction().filter(seleniumQueryObject, filterFunction); }
public SeleniumQueryObject filterSelector(SeleniumQueryObject seleniumQueryObject, String selector) { return new FilterSelectorFunction().filter(seleniumQueryObject, selector); }
@Override public SeleniumQueryObject apply(SeleniumQueryObject targetSQO) { return filterSelectorFunction.filter(targetSQO, SELECTOR_DOES_NOT_MATTER_IN_THIS_TEST); } });
@Test public void resultSQO_should_have_targetSQO_as_previous_object__and_same_SQFunctions_as_targetSQO__and_same_WebDriver_as_targetSQO() { FunctionsTestUtils.verifyFunctionReturnsSQOWithCorrectWebDriverAndFunctionsAndPrevious(targetSQO -> filterPredicateFunction.filter(targetSQO, PREDICATE_DOES_NOT_MATTER_IN_THIS_TEST)); }
public SeleniumQueryObject filter(SeleniumQueryObject seleniumQueryObject, Predicate<WebElement> filterFunction) { List<WebElement> filteredWebElements = filterWebElements(seleniumQueryObject.get(), filterFunction); return instance().create(seleniumQueryObject.getSeleniumQueryFunctions(), seleniumQueryObject.getWebDriver(), new SeleniumQueryInvalidBy(seleniumQueryObject.getBy(), ".filter(<function>)"), filteredWebElements, seleniumQueryObject); }
public SeleniumQueryObject filter(SeleniumQueryObject seleniumQueryObject, String selector) { List<WebElement> filteredWebElements = filterElements(seleniumQueryObject, selector); return instance().create(seleniumQueryObject.getSeleniumQueryFunctions(), seleniumQueryObject.getWebDriver(), new SeleniumQueryInvalidBy(seleniumQueryObject.getBy(), ".filter(\""+selector+"\")"), filteredWebElements, seleniumQueryObject); }
public SeleniumQueryObject filterPredicate(SeleniumQueryObject seleniumQueryObject, Predicate<WebElement> filterFunction) { return new FilterPredicateFunction().filter(seleniumQueryObject, filterFunction); }
public SeleniumQueryObject filterSelector(SeleniumQueryObject seleniumQueryObject, String selector) { return new FilterSelectorFunction().filter(seleniumQueryObject, selector); }
@Test public void null_selector__should_return_EMPTY_element_set() { // given SeleniumQueryObject targetSQO = createStubSeleniumQueryObjectWithAtLeastOneElement(); // when SeleniumQueryObject resultSQO = filterSelectorFunction.filter(targetSQO, NULL_SELECTOR); // then assertThat(resultSQO.get(), empty()); }
@Test public void null_predicate__should_return_EMPTY_element_set() { // given SeleniumQueryObject targetSQO = createStubSeleniumQueryObjectWithAtLeastOneElement(); // when SeleniumQueryObject resultSQO = filterPredicateFunction.filter(targetSQO, NULL_PREDICATE); // then assertThat(resultSQO.get(), empty()); }
public SeleniumQueryObject filter(SeleniumQueryObject seleniumQueryObject, Predicate<WebElement> filterFunction) { List<WebElement> filteredWebElements = filterWebElements(seleniumQueryObject.get(), filterFunction); return instance().create(seleniumQueryObject.getSeleniumQueryFunctions(), seleniumQueryObject.getWebDriver(), new SeleniumQueryInvalidBy(seleniumQueryObject.getBy(), ".filter(<function>)"), filteredWebElements, seleniumQueryObject); }
public SeleniumQueryObject filter(SeleniumQueryObject seleniumQueryObject, String selector) { List<WebElement> filteredWebElements = filterElements(seleniumQueryObject, selector); return instance().create(seleniumQueryObject.getSeleniumQueryFunctions(), seleniumQueryObject.getWebDriver(), new SeleniumQueryInvalidBy(seleniumQueryObject.getBy(), ".filter(\""+selector+"\")"), filteredWebElements, seleniumQueryObject); }
@Test public void emptyString_selector__should_return_EMPTY_element_set() { // given SeleniumQueryObject targetSQO = createStubSeleniumQueryObjectWithAtLeastOneElement(); // when SeleniumQueryObject resultSQO = filterSelectorFunction.filter(targetSQO, ""); // then assertThat(resultSQO.get(), empty()); }
@Test public void filterred_object_should_have_invalidBy_as_by() { // given SeleniumQueryObject targetSQO = createStubSeleniumQueryObjectWithElements(createWebElementWithTag("doesnt-matter")); // when SeleniumQueryObject resultSQO = filterPredicateFunction.filter(targetSQO, NULL_PREDICATE); // then assertThat(resultSQO.getBy(), instanceOf(SeleniumQueryInvalidBy.class)); assertThat(resultSQO.getBy().toString(), equalTo("$(\"dummy#by\").filter(<function>)") ); }
@Test public void filterred_object_should_have_invalidBy_as_by() { // given SeleniumQueryObject targetSQO = createStubSeleniumQueryObjectWithElements(createWebElementWithTag("doesnt-matter")); // when SeleniumQueryObject resultSQO = filterSelectorFunction.filter(targetSQO, "div#bob.yes:some-selector"); // then assertThat(resultSQO.getBy(), instanceOf(SeleniumQueryInvalidBy.class)); assertThat(resultSQO.getBy().toString(), equalTo("$(\"dummy#by\").filter(\"div#bob.yes:some-selector\")") ); }
@Test public void resultSQO_should_onlyKeepElementsThatPassThePredicateFunction() { // given WebElement spanOne = createWebElementWithTag("span"); WebElement notSpan = createWebElementWithTag("div"); WebElement spanTwo = createWebElementWithTag("span"); SeleniumQueryObject targetSQO = createStubSeleniumQueryObjectWithElements(spanOne, notSpan, spanTwo); // when SeleniumQueryObject resultSQO = filterPredicateFunction.filter(targetSQO, e -> "span".equals(e.getTagName())); // then assertThat(resultSQO.get(), contains(spanOne, spanTwo)); }
@Test public void resultSQO_should_onlyKeepElementsThatMatchTheSelector() { // given WebElement spanOne = createWebElementWithTag("span"); WebElement notSpan = createWebElementWithTag("div"); WebElement spanTwo = createWebElementWithTag("span"); SeleniumQueryObject targetSQO = createStubSeleniumQueryObjectWithElements(spanOne, notSpan, spanTwo); // when SeleniumQueryObject resultSQO = filterSelectorFunction.filter(targetSQO, "span"); // then assertThat(resultSQO.get(), contains(spanOne, spanTwo)); }