@Override public SeleniumQueryObject apply(SeleniumQueryObject targetSQO) { return filterSelectorFunction.filter(targetSQO, SELECTOR_DOES_NOT_MATTER_IN_THIS_TEST); } });
public SeleniumQueryObject filterSelector(SeleniumQueryObject seleniumQueryObject, String selector) { return new FilterSelectorFunction().filter(seleniumQueryObject, selector); }
public SeleniumQueryObject filterSelector(SeleniumQueryObject seleniumQueryObject, String selector) { return new FilterSelectorFunction().filter(seleniumQueryObject, selector); }
@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 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 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 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)); }