MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / querySelectorAll

Method querySelectorAll

src/main/java/org/htmlunit/html/DomNode.java:2046–2067  ·  view source on GitHub ↗

Retrieves all element nodes from descendants of the starting element node that match any selector within the supplied selector strings. @param selectors one or more CSS selectors separated by commas @return list of all found nodes

(final String selectors)

Source from the content-addressed store, hash-verified

2044 * @return list of all found nodes
2045 */
2046 public DomNodeList<DomNode> querySelectorAll(final String selectors) {
2047 try {
2048 final WebClient webClient = getPage().getWebClient();
2049 final SelectorList selectorList = getSelectorList(selectors, webClient);
2050
2051 final List<DomNode> elements = new ArrayList<>();
2052 if (selectorList != null) {
2053 for (final DomElement child : getDomElementDescendants()) {
2054 for (final Selector selector : selectorList) {
2055 if (CssStyleSheet.selects(webClient.getBrowserVersion(), selector, child, null, true, true)) {
2056 elements.add(child);
2057 break;
2058 }
2059 }
2060 }
2061 }
2062 return new StaticDomNodeList(elements);
2063 }
2064 catch (final IOException e) {
2065 throw new CSSException("Error parsing CSS selectors from '" + selectors + "': " + e.getMessage(), e);
2066 }
2067 }
2068
2069 /**
2070 * Returns the {@link SelectorList}.

Callers 1

querySelectorMethod · 0.95

Calls 8

getPageMethod · 0.95
getSelectorListMethod · 0.95
selectsMethod · 0.95
getBrowserVersionMethod · 0.95
getMessageMethod · 0.80
getWebClientMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected