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

org.openqa.selenium.devtools.v90.domdebugger.DOMDebugger 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.0.0-beta-4
Show newest version
package org.openqa.selenium.devtools.v90.domdebugger;

import org.openqa.selenium.Beta;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.ConverterFunctions;
import com.google.common.collect.ImmutableMap;
import org.openqa.selenium.json.JsonInput;

/**
 * DOM debugging allows setting breakpoints on particular DOM operations and events. JavaScript
 * execution will stop on these operations as if there was a regular breakpoint set.
 */
public class DOMDebugger {

    /**
     * Returns event listeners of the given object.
     */
    public static Command> getEventListeners(org.openqa.selenium.devtools.v90.runtime.model.RemoteObjectId objectId, java.util.Optional depth, java.util.Optional pierce) {
        java.util.Objects.requireNonNull(objectId, "objectId is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("objectId", objectId);
        depth.ifPresent(p -> params.put("depth", p));
        pierce.ifPresent(p -> params.put("pierce", p));
        return new Command<>("DOMDebugger.getEventListeners", params.build(), ConverterFunctions.map("listeners", new com.google.common.reflect.TypeToken>() {
        }.getType()));
    }

    /**
     * Removes DOM breakpoint that was set using `setDOMBreakpoint`.
     */
    public static Command removeDOMBreakpoint(org.openqa.selenium.devtools.v90.dom.model.NodeId nodeId, org.openqa.selenium.devtools.v90.domdebugger.model.DOMBreakpointType type) {
        java.util.Objects.requireNonNull(nodeId, "nodeId is required");
        java.util.Objects.requireNonNull(type, "type is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("nodeId", nodeId);
        params.put("type", type);
        return new Command<>("DOMDebugger.removeDOMBreakpoint", params.build());
    }

    /**
     * Removes breakpoint on particular DOM event.
     */
    public static Command removeEventListenerBreakpoint(java.lang.String eventName, java.util.Optional targetName) {
        java.util.Objects.requireNonNull(eventName, "eventName is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("eventName", eventName);
        targetName.ifPresent(p -> params.put("targetName", p));
        return new Command<>("DOMDebugger.removeEventListenerBreakpoint", params.build());
    }

    /**
     * Removes breakpoint on particular native event.
     */
    @Beta()
    public static Command removeInstrumentationBreakpoint(java.lang.String eventName) {
        java.util.Objects.requireNonNull(eventName, "eventName is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("eventName", eventName);
        return new Command<>("DOMDebugger.removeInstrumentationBreakpoint", params.build());
    }

    /**
     * Removes breakpoint from XMLHttpRequest.
     */
    public static Command removeXHRBreakpoint(java.lang.String url) {
        java.util.Objects.requireNonNull(url, "url is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("url", url);
        return new Command<>("DOMDebugger.removeXHRBreakpoint", params.build());
    }

    /**
     * Sets breakpoint on particular CSP violations.
     */
    @Beta()
    public static Command setBreakOnCSPViolation(java.util.List violationTypes) {
        java.util.Objects.requireNonNull(violationTypes, "violationTypes is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("violationTypes", violationTypes);
        return new Command<>("DOMDebugger.setBreakOnCSPViolation", params.build());
    }

    /**
     * Sets breakpoint on particular operation with DOM.
     */
    public static Command setDOMBreakpoint(org.openqa.selenium.devtools.v90.dom.model.NodeId nodeId, org.openqa.selenium.devtools.v90.domdebugger.model.DOMBreakpointType type) {
        java.util.Objects.requireNonNull(nodeId, "nodeId is required");
        java.util.Objects.requireNonNull(type, "type is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("nodeId", nodeId);
        params.put("type", type);
        return new Command<>("DOMDebugger.setDOMBreakpoint", params.build());
    }

    /**
     * Sets breakpoint on particular DOM event.
     */
    public static Command setEventListenerBreakpoint(java.lang.String eventName, java.util.Optional targetName) {
        java.util.Objects.requireNonNull(eventName, "eventName is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("eventName", eventName);
        targetName.ifPresent(p -> params.put("targetName", p));
        return new Command<>("DOMDebugger.setEventListenerBreakpoint", params.build());
    }

    /**
     * Sets breakpoint on particular native event.
     */
    @Beta()
    public static Command setInstrumentationBreakpoint(java.lang.String eventName) {
        java.util.Objects.requireNonNull(eventName, "eventName is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("eventName", eventName);
        return new Command<>("DOMDebugger.setInstrumentationBreakpoint", params.build());
    }

    /**
     * Sets breakpoint on XMLHttpRequest.
     */
    public static Command setXHRBreakpoint(java.lang.String url) {
        java.util.Objects.requireNonNull(url, "url is required");
        ImmutableMap.Builder params = ImmutableMap.builder();
        params.put("url", url);
        return new Command<>("DOMDebugger.setXHRBreakpoint", params.build());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy