com.hubspot.chrome.devtools.client.core.accessibility.Accessibility Maven / Gradle / Ivy
package com.hubspot.chrome.devtools.client.core.accessibility;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hubspot.chrome.devtools.base.ChromeRequest;
import com.hubspot.chrome.devtools.base.ChromeSessionCore;
import com.hubspot.chrome.devtools.client.core.dom.NodeId;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public final class Accessibility {
ChromeSessionCore chromeSession;
ObjectMapper objectMapper;
public Accessibility(ChromeSessionCore chromeSession, ObjectMapper objectMapper) {
this.chromeSession = chromeSession;
this.objectMapper = objectMapper;
}
/**
* Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.
*
* @param nodeId ID of node to get the partial accessibility tree for.
* @param fetchRelatives [Optional] Whether to fetch this nodes ancestors, siblings and children. Defaults to true.
*/
public List getPartialAXTree(NodeId nodeId, Boolean fetchRelatives) {
ChromeRequest chromeRequest = new ChromeRequest("Accessibility.getPartialAXTree");
chromeRequest
.putParams("nodeId", nodeId)
.putParams("fetchRelatives", fetchRelatives);
return chromeSession.send(chromeRequest, new TypeReference>(){});
}
/**
* Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.
*
* @param nodeId ID of node to get the partial accessibility tree for.
* @param fetchRelatives [Optional] Whether to fetch this nodes ancestors, siblings and children. Defaults to true.
*/
public CompletableFuture> getPartialAXTreeAsync(NodeId nodeId,
Boolean fetchRelatives) {
ChromeRequest chromeRequest = new ChromeRequest("Accessibility.getPartialAXTree");
chromeRequest
.putParams("nodeId", nodeId)
.putParams("fetchRelatives", fetchRelatives);
return chromeSession.sendAsync(chromeRequest, new TypeReference>(){});
}
}