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

org.openqa.selenium.devtools.v121.layertree.LayerTree Maven / Gradle / Ivy

Go to download

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

There is a newer version: 4.19.1
Show newest version
package org.openqa.selenium.devtools.v121.layertree;

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 LayerTree {

    public static class CompositingReasonsResponse {

        private final java.util.List compositingReasons;

        private final java.util.List compositingReasonIds;

        public CompositingReasonsResponse(java.util.List compositingReasons, java.util.List compositingReasonIds) {
            this.compositingReasons = java.util.Objects.requireNonNull(compositingReasons, "compositingReasons is required");
            this.compositingReasonIds = java.util.Objects.requireNonNull(compositingReasonIds, "compositingReasonIds is required");
        }

        /**
         * A list of strings specifying reasons for the given layer to become composited.
         */
        public java.util.List getCompositingReasons() {
            return compositingReasons;
        }

        /**
         * A list of strings specifying reason IDs for the given layer to become composited.
         */
        public java.util.List getCompositingReasonIds() {
            return compositingReasonIds;
        }

        private static CompositingReasonsResponse fromJson(JsonInput input) {
            java.util.List compositingReasons = null;
            java.util.List compositingReasonIds = null;
            input.beginObject();
            while (input.hasNext()) {
                switch(input.nextName()) {
                    case "compositingReasons":
                        compositingReasons = input.readArray(java.lang.String.class);
                        break;
                    case "compositingReasonIds":
                        compositingReasonIds = input.readArray(java.lang.String.class);
                        break;
                    default:
                        input.skipValue();
                        break;
                }
            }
            input.endObject();
            return new CompositingReasonsResponse(compositingReasons, compositingReasonIds);
        }
    }

    /**
     * Provides the reasons why the given layer was composited.
     */
    public static Command compositingReasons(org.openqa.selenium.devtools.v121.layertree.model.LayerId layerId) {
        java.util.Objects.requireNonNull(layerId, "layerId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("layerId", layerId);
        return new Command<>("LayerTree.compositingReasons", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v121.layertree.LayerTree.CompositingReasonsResponse.class));
    }

    /**
     * Disables compositing tree inspection.
     */
    public static Command disable() {
        LinkedHashMap params = new LinkedHashMap<>();
        return new Command<>("LayerTree.disable", Map.copyOf(params));
    }

    /**
     * Enables compositing tree inspection.
     */
    public static Command enable() {
        LinkedHashMap params = new LinkedHashMap<>();
        return new Command<>("LayerTree.enable", Map.copyOf(params));
    }

    /**
     * Returns the snapshot identifier.
     */
    public static Command loadSnapshot(java.util.List tiles) {
        java.util.Objects.requireNonNull(tiles, "tiles is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("tiles", tiles);
        return new Command<>("LayerTree.loadSnapshot", Map.copyOf(params), ConverterFunctions.map("snapshotId", org.openqa.selenium.devtools.v121.layertree.model.SnapshotId.class));
    }

    /**
     * Returns the layer snapshot identifier.
     */
    public static Command makeSnapshot(org.openqa.selenium.devtools.v121.layertree.model.LayerId layerId) {
        java.util.Objects.requireNonNull(layerId, "layerId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("layerId", layerId);
        return new Command<>("LayerTree.makeSnapshot", Map.copyOf(params), ConverterFunctions.map("snapshotId", org.openqa.selenium.devtools.v121.layertree.model.SnapshotId.class));
    }

    public static Command> profileSnapshot(org.openqa.selenium.devtools.v121.layertree.model.SnapshotId snapshotId, java.util.Optional minRepeatCount, java.util.Optional minDuration, java.util.Optional clipRect) {
        java.util.Objects.requireNonNull(snapshotId, "snapshotId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("snapshotId", snapshotId);
        minRepeatCount.ifPresent(p -> params.put("minRepeatCount", p));
        minDuration.ifPresent(p -> params.put("minDuration", p));
        clipRect.ifPresent(p -> params.put("clipRect", p));
        return new Command<>("LayerTree.profileSnapshot", Map.copyOf(params), ConverterFunctions.map("timings", input -> input.readArray(org.openqa.selenium.devtools.v121.layertree.model.PaintProfile.class)));
    }

    /**
     * Releases layer snapshot captured by the back-end.
     */
    public static Command releaseSnapshot(org.openqa.selenium.devtools.v121.layertree.model.SnapshotId snapshotId) {
        java.util.Objects.requireNonNull(snapshotId, "snapshotId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("snapshotId", snapshotId);
        return new Command<>("LayerTree.releaseSnapshot", Map.copyOf(params));
    }

    /**
     * Replays the layer snapshot and returns the resulting bitmap.
     */
    public static Command replaySnapshot(org.openqa.selenium.devtools.v121.layertree.model.SnapshotId snapshotId, java.util.Optional fromStep, java.util.Optional toStep, java.util.Optional scale) {
        java.util.Objects.requireNonNull(snapshotId, "snapshotId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("snapshotId", snapshotId);
        fromStep.ifPresent(p -> params.put("fromStep", p));
        toStep.ifPresent(p -> params.put("toStep", p));
        scale.ifPresent(p -> params.put("scale", p));
        return new Command<>("LayerTree.replaySnapshot", Map.copyOf(params), ConverterFunctions.map("dataURL", java.lang.String.class));
    }

    /**
     * Replays the layer snapshot and returns canvas log.
     */
    public static Command>> snapshotCommandLog(org.openqa.selenium.devtools.v121.layertree.model.SnapshotId snapshotId) {
        java.util.Objects.requireNonNull(snapshotId, "snapshotId is required");
        LinkedHashMap params = new LinkedHashMap<>();
        params.put("snapshotId", snapshotId);
        return new Command<>("LayerTree.snapshotCommandLog", Map.copyOf(params), ConverterFunctions.map("commandLog", input -> input.readArray(java.util.Map.class)));
    }

    public static Event layerPainted() {
        return new Event<>("LayerTree.layerPainted", input -> input.read(org.openqa.selenium.devtools.v121.layertree.model.LayerPainted.class));
    }

    public static Event> layerTreeDidChange() {
        return new Event<>("LayerTree.layerTreeDidChange", ConverterFunctions.map("layers", input -> input.readArray(org.openqa.selenium.devtools.v121.layertree.model.Layer.class)));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy