@param filter a predicate to filter the element @return all elements attached to this form and matching the filter predicate
(final Predicate<HtmlElement> filter)
| 605 | * @return all elements attached to this form and matching the filter predicate |
| 606 | */ |
| 607 | public List<HtmlElement> getElements(final Predicate<HtmlElement> filter) { |
| 608 | final List<HtmlElement> elements = new ArrayList<>(); |
| 609 | |
| 610 | if (isAttachedToPage()) { |
| 611 | for (final HtmlElement element : getPage().getDocumentElement().getHtmlElementDescendants()) { |
| 612 | if (filter.test(element) |
| 613 | && element.getEnclosingForm() == this) { |
| 614 | elements.add(element); |
| 615 | } |
| 616 | } |
| 617 | } |
| 618 | else { |
| 619 | for (final HtmlElement element : getHtmlElementDescendants()) { |
| 620 | if (filter.test(element)) { |
| 621 | elements.add(element); |
| 622 | } |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | return elements; |
| 627 | } |
| 628 | |
| 629 | /** |
| 630 | * Returns the first input element which is a member of this form and has the specified name. |
no test coverage detected