All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openqa.selenium.devtools.v127.accessibility.Accessibility Maven / Gradle / Ivy

Go to download

Selenium automates browsers. That's it! What you do with that power is entirely up to you.

The newest version!
package org.openqa.selenium.devtools.v127.accessibility;

import org.openqa.selenium.Beta;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.ConverterFunctions;
import java.util.Map;
import java.util.LinkedHashMap;
import org.openqa.selenium.json.JsonInput;

@Beta()
public class Accessibility {

    /**
     * Disables the accessibility domain.
     */
    public static Command disable() {
        LinkedHashMap params = new LinkedHashMap<>();
        return new Command<>("Accessibility.disable", Map.copyOf(params));
    }

    /**
     * Enables the accessibility domain which causes `AXNodeId`s to remain consistent between method calls.
     * This turns on accessibility for the page, which can impact performance until accessibility is disabled.
     */
    public static Command enable() {
        LinkedHashMap params = new LinkedHashMap<>();
        return new Command<>("Accessibility.enable", Map.copyOf(params));
    }

    /**
     * Fetches the accessibility node and partial accessibility tree for this DOM node, if it exists.
     */
    @Beta()
    public static Command> getPartialAXTree(java.util.Optional nodeId, java.util.Optional backendNodeId, java.util.Optional objectId, java.util.Optional fetchRelatives) {
        LinkedHashMap params = new LinkedHashMap<>();
        nodeId.ifPresent(p -> params.put("nodeId", p));
        backendNodeId.ifPresent(p -> params.put("backendNodeId", p));
        objectId.ifPresent(p -> params.put("objectId", p));
        fetchRelatives.ifPresent(p -> params.put("fetchRelatives", p));
        return new Command<>("Accessibility.getPartialAXTree", Map.copyOf(params), ConverterFunctions.map("nodes", input -> input.readArray(org.openqa.selenium.devtools.v127.accessibility.model.AXNode.class)));
    }

    /**
     * Fetches the entire accessibility tree for the root Document
     */
    @Beta()
    public static Command> getFullAXTree(java.util.Optional depth, java.util.Optional frameId) {
        LinkedHashMap params = new LinkedHashMap<>();
        depth.ifPresent(p -> params.put("depth", p));
        frameId.ifPresent(p -> params.put("frameId", p));
        return new Command<>("Accessibility.getFullAXTree", Map.copyOf(params), ConverterFunctions.map("nodes", input -> input.readArray(org.openqa.selenium.devtools.v127.accessibility.model.AXNode.class)));
    }

    /**
     * Fetches the root node.
     * Requires `enable()` to have been called previously.
     */
    @Beta()
    public static Command getRootAXNode(java.util.Optional frameId) {
        LinkedHashMap params = new LinkedHashMap<>();
        frameId.ifPresent(p -> params.put("frameId", p));
        return new Command<>("Accessibility.getRootAXNode", Map.copyOf(params), ConverterFunctions.map("node", org.openqa.selenium.devtools.v127.accessibility.model.AXNode.class));
    }

    /**
     * Fetches a node and all ancestors up to and including the root.
     * Requires `enable()` to have been called previously.
     */
    @Beta()
    public static Command> getAXNodeAndAncestors(java.util.Optional nodeId, java.util.Optional backendNodeId, java.util.Optional objectId) {
        LinkedHashMap params = new LinkedHashMap<>();
        nodeId.ifPresent(p -> params.put("nodeId", p));
        backendNodeId.ifPresent(p -> params.put("backendNodeId", p));
        objectId.ifPresent(p -> params.put("objectId", p));
        return new Command<>("Accessibility.getAXNodeAndAncestors", Map.copyOf(params), ConverterFunctions.map("nodes", input -> input.readArray(org.openqa.selenium.devtools.v127.accessibility.model.AXNode.class)));
    }

    /**
     * Fetches a particular accessibility node by AXNodeId.
     * Requires `enable()` to have been called previously.
     */
    @Beta()
    public static Command> getChildAXNodes(org.openqa.selenium.devtools.v127.accessibility.model.AXNodeId id, java.util.Optional frameId) {
        java.util.Objects.requireNonNull(id, "id is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("id", id);
        frameId.ifPresent(p -> params.put("frameId", p));
        return new Command<>("Accessibility.getChildAXNodes", Map.copyOf(params), ConverterFunctions.map("nodes", input -> input.readArray(org.openqa.selenium.devtools.v127.accessibility.model.AXNode.class)));
    }

    /**
     * Query a DOM node's accessibility subtree for accessible name and role.
     * This command computes the name and role for all nodes in the subtree, including those that are
     * ignored for accessibility, and returns those that match the specified name and role. If no DOM
     * node is specified, or the DOM node does not exist, the command returns an error. If neither
     * `accessibleName` or `role` is specified, it returns all the accessibility nodes in the subtree.
     */
    @Beta()
    public static Command> queryAXTree(java.util.Optional nodeId, java.util.Optional backendNodeId, java.util.Optional objectId, java.util.Optional accessibleName, java.util.Optional role) {
        LinkedHashMap params = new LinkedHashMap<>();
        nodeId.ifPresent(p -> params.put("nodeId", p));
        backendNodeId.ifPresent(p -> params.put("backendNodeId", p));
        objectId.ifPresent(p -> params.put("objectId", p));
        accessibleName.ifPresent(p -> params.put("accessibleName", p));
        role.ifPresent(p -> params.put("role", p));
        return new Command<>("Accessibility.queryAXTree", Map.copyOf(params), ConverterFunctions.map("nodes", input -> input.readArray(org.openqa.selenium.devtools.v127.accessibility.model.AXNode.class)));
    }

    public static Event loadComplete() {
        return new Event<>("Accessibility.loadComplete", ConverterFunctions.map("root", org.openqa.selenium.devtools.v127.accessibility.model.AXNode.class));
    }

    public static Event> nodesUpdated() {
        return new Event<>("Accessibility.nodesUpdated", ConverterFunctions.map("nodes", input -> input.readArray(org.openqa.selenium.devtools.v127.accessibility.model.AXNode.class)));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy