8000 #97 Added $().filter("selector") to SeleniumQueryObject · seleniumQuery/seleniumQuery@2cb8d9b · GitHub
[go: up one dir, main page]

Skip to content

Commit 2cb8d9b

Browse files
committed
#97 Added $().filter("selector") to SeleniumQueryObject
1 parent a9d2b27 commit 2cb8d9b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/main/java/io/github/seleniumquery/SeleniumQueryObject.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,4 +642,15 @@ public SeleniumQueryObject filter(Predicate<WebElement> filterFunction) {
642642
return seleniumQueryFunctions.filterPredicate(this, filterFunction);
643643
}
644644

645+
/**
646+
* Reduce the set of matched elements to those that match the given selector.
647+
*
648+
* @param selector A string containing a selector expression to match the current set of elements against.
649+
* @return An object with the elements that matched the selector.
650+
* @since 0.11.0
651+
*/
652+
public SeleniumQueryObject filter(String selector) {
653+
return seleniumQueryFunctions.filterSelector(this, selector);
654+
}
655+
645656
}

src/main/java/io/github/seleniumquery/functions/SeleniumQueryFunctions.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015 seleniumQuery authors
2+
* Copyright (c) 2016 seleniumQuery authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
import io.github.seleniumquery.functions.jquery.miscellaneous.ToArrayFunction;
3333
import io.github.seleniumquery.functions.jquery.traversing.filtering.*;
3434
import io.github.seleniumquery.functions.jquery.traversing.filtering.filterfunction.FilterPredicateFunction;
35+
import io.github.seleniumquery.functions.jquery.traversing.filtering.filterfunction.FilterSelectorFunction;
3536
import io.github.seleniumquery.functions.jquery.traversing.treetraversal.ChildrenFunction;
3637
import io.github.seleniumquery.functions.jquery.traversing.treetraversal.ClosestFunction;
3738
import io.github.seleniumquery.functions.jquery.traversing.treetraversal.FindFunction;
@@ -64,6 +65,10 @@ public SeleniumQueryObject filterPredicate(SeleniumQueryObject seleniumQueryObje
6465
return new FilterPredicateFunction().filter(seleniumQueryObject, filterFunction);
6566
}
6667

68+
public SeleniumQueryObject filterSelector(SeleniumQueryObject seleniumQueryObject, String selector) {
69+
return new FilterSelectorFunction().filter(seleniumQueryObject, selector);
70+
}
71+
6772
public boolean isSelector(SeleniumQueryObject seleniumQueryObject, String selector) {
6873
return IsFunction.is(seleniumQueryObject, selector);
6974
}

src/test/java/testinfrastructure/testdouble/io/github/seleniumquery/functions/SeleniumQueryFunctionsMock.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public class SeleniumQueryFunctionsMock extends SeleniumQueryFunctions {
4242
public MethodMockConfiguration<SeleniumQueryObject> filterPredicateMethod;
4343
@Override public SeleniumQueryObject filterPredicate(SeleniumQueryObject s, Predicate<WebElement> f) { return filterPredicateMethod.executeMethodMock(s, f); }
4444

45+
public MethodMockConfiguration<SeleniumQueryObject> filterSelectorMethod;
46+
@Override public SeleniumQueryObject filterSelector(SeleniumQueryObject s, String e) { return filterSelectorMethod.executeMethodMock(s, e); }
47+
4548
public MethodMockConfiguration<Boolean> isSelectorMethod;
4649
@Override public boolean isSelector(SeleniumQueryObject s, String e) { return isSelectorMethod.executeMethodMock(s, e); }
4750

0 commit comments

Comments
 (0)
0