org.openqa.selenium.devtools.v85.debugger.Debugger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selenium-devtools-v85 Show documentation
Show all versions of selenium-devtools-v85 Show documentation
Selenium automates browsers. That's it! What you do with that power is entirely up to you.
package org.openqa.selenium.devtools.v85.debugger;
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;
/**
* Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing
* breakpoints, stepping through execution, exploring stack traces, etc.
*/
public class Debugger {
public enum ContinueToLocationTargetCallFrames {
ANY("any"), CURRENT("current");
private String value;
ContinueToLocationTargetCallFrames(String value) {
this.value = value;
}
public static ContinueToLocationTargetCallFrames fromString(String s) {
return java.util.Arrays.stream(ContinueToLocationTargetCallFrames.values()).filter(rs -> rs.value.equalsIgnoreCase(s)).findFirst().orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException("Given value " + s + " is not found within ContinueToLocationTargetCallFrames "));
}
public String toString() {
return value;
}
public String toJson() {
return value;
}
private static ContinueToLocationTargetCallFrames fromJson(JsonInput input) {
return fromString(input.nextString());
}
}
/**
* Continues execution until specific location is reached.
*/
public static Command continueToLocation(org.openqa.selenium.devtools.v85.debugger.model.Location location, java.util.Optional targetCallFrames) {
java.util.Objects.requireNonNull(location, "location is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("location", location);
targetCallFrames.ifPresent(p -> params.put("targetCallFrames", p));
return new Command<>("Debugger.continueToLocation", Map.copyOf(params));
}
/**
* Disables debugger for given page.
*/
public static Command disable() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Debugger.disable", Map.copyOf(params));
}
/**
* Enables debugger for the given page. Clients should not assume that the debugging has been
* enabled until the result for this command is received.
*/
public static Command enable(java.util.Optional maxScriptsCacheSize) {
LinkedHashMap params = new LinkedHashMap<>();
maxScriptsCacheSize.ifPresent(p -> params.put("maxScriptsCacheSize", p));
return new Command<>("Debugger.enable", Map.copyOf(params), ConverterFunctions.map("debuggerId", org.openqa.selenium.devtools.v85.runtime.model.UniqueDebuggerId.class));
}
public static class EvaluateOnCallFrameResponse {
private final org.openqa.selenium.devtools.v85.runtime.model.RemoteObject result;
private final java.util.Optional exceptionDetails;
public EvaluateOnCallFrameResponse(org.openqa.selenium.devtools.v85.runtime.model.RemoteObject result, java.util.Optional exceptionDetails) {
this.result = java.util.Objects.requireNonNull(result, "result is required");
this.exceptionDetails = exceptionDetails;
}
/**
* Object wrapper for the evaluation result.
*/
public org.openqa.selenium.devtools.v85.runtime.model.RemoteObject getResult() {
return result;
}
/**
* Exception details.
*/
public java.util.Optional getExceptionDetails() {
return exceptionDetails;
}
private static EvaluateOnCallFrameResponse fromJson(JsonInput input) {
org.openqa.selenium.devtools.v85.runtime.model.RemoteObject result = null;
java.util.Optional exceptionDetails = java.util.Optional.empty();
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "result":
result = input.read(org.openqa.selenium.devtools.v85.runtime.model.RemoteObject.class);
break;
case "exceptionDetails":
exceptionDetails = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v85.runtime.model.ExceptionDetails.class));
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new EvaluateOnCallFrameResponse(result, exceptionDetails);
}
}
/**
* Evaluates expression on a given call frame.
*/
public static Command evaluateOnCallFrame(org.openqa.selenium.devtools.v85.debugger.model.CallFrameId callFrameId, java.lang.String expression, java.util.Optional objectGroup, java.util.Optional includeCommandLineAPI, java.util.Optional silent, java.util.Optional returnByValue, java.util.Optional generatePreview, java.util.Optional throwOnSideEffect, java.util.Optional timeout) {
java.util.Objects.requireNonNull(callFrameId, "callFrameId is required");
java.util.Objects.requireNonNull(expression, "expression is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("callFrameId", callFrameId);
params.put("expression", expression);
objectGroup.ifPresent(p -> params.put("objectGroup", p));
includeCommandLineAPI.ifPresent(p -> params.put("includeCommandLineAPI", p));
silent.ifPresent(p -> params.put("silent", p));
returnByValue.ifPresent(p -> params.put("returnByValue", p));
generatePreview.ifPresent(p -> params.put("generatePreview", p));
throwOnSideEffect.ifPresent(p -> params.put("throwOnSideEffect", p));
timeout.ifPresent(p -> params.put("timeout", p));
return new Command<>("Debugger.evaluateOnCallFrame", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v85.debugger.Debugger.EvaluateOnCallFrameResponse.class));
}
public static class ExecuteWasmEvaluatorResponse {
private final org.openqa.selenium.devtools.v85.runtime.model.RemoteObject result;
private final java.util.Optional exceptionDetails;
public ExecuteWasmEvaluatorResponse(org.openqa.selenium.devtools.v85.runtime.model.RemoteObject result, java.util.Optional exceptionDetails) {
this.result = java.util.Objects.requireNonNull(result, "result is required");
this.exceptionDetails = exceptionDetails;
}
/**
* Object wrapper for the evaluation result.
*/
public org.openqa.selenium.devtools.v85.runtime.model.RemoteObject getResult() {
return result;
}
/**
* Exception details.
*/
public java.util.Optional getExceptionDetails() {
return exceptionDetails;
}
private static ExecuteWasmEvaluatorResponse fromJson(JsonInput input) {
org.openqa.selenium.devtools.v85.runtime.model.RemoteObject result = null;
java.util.Optional exceptionDetails = java.util.Optional.empty();
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "result":
result = input.read(org.openqa.selenium.devtools.v85.runtime.model.RemoteObject.class);
break;
case "exceptionDetails":
exceptionDetails = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v85.runtime.model.ExceptionDetails.class));
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new ExecuteWasmEvaluatorResponse(result, exceptionDetails);
}
}
/**
* Execute a Wasm Evaluator module on a given call frame.
*/
@Beta()
public static Command executeWasmEvaluator(org.openqa.selenium.devtools.v85.debugger.model.CallFrameId callFrameId, java.lang.String evaluator, java.util.Optional timeout) {
java.util.Objects.requireNonNull(callFrameId, "callFrameId is required");
java.util.Objects.requireNonNull(evaluator, "evaluator is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("callFrameId", callFrameId);
params.put("evaluator", evaluator);
timeout.ifPresent(p -> params.put("timeout", p));
return new Command<>("Debugger.executeWasmEvaluator", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v85.debugger.Debugger.ExecuteWasmEvaluatorResponse.class));
}
/**
* Returns possible locations for breakpoint. scriptId in start and end range locations should be
* the same.
*/
public static Command> getPossibleBreakpoints(org.openqa.selenium.devtools.v85.debugger.model.Location start, java.util.Optional end, java.util.Optional restrictToFunction) {
java.util.Objects.requireNonNull(start, "start is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("start", start);
end.ifPresent(p -> params.put("end", p));
restrictToFunction.ifPresent(p -> params.put("restrictToFunction", p));
return new Command<>("Debugger.getPossibleBreakpoints", Map.copyOf(params), ConverterFunctions.map("locations", input -> input.readArray(org.openqa.selenium.devtools.v85.debugger.model.BreakLocation.class)));
}
public static class GetScriptSourceResponse {
private final java.lang.String scriptSource;
private final java.util.Optional bytecode;
public GetScriptSourceResponse(java.lang.String scriptSource, java.util.Optional bytecode) {
this.scriptSource = java.util.Objects.requireNonNull(scriptSource, "scriptSource is required");
this.bytecode = bytecode;
}
/**
* Script source (empty in case of Wasm bytecode).
*/
public java.lang.String getScriptSource() {
return scriptSource;
}
/**
* Wasm bytecode.
*/
public java.util.Optional getBytecode() {
return bytecode;
}
private static GetScriptSourceResponse fromJson(JsonInput input) {
java.lang.String scriptSource = null;
java.util.Optional bytecode = java.util.Optional.empty();
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "scriptSource":
scriptSource = input.nextString();
break;
case "bytecode":
bytecode = java.util.Optional.ofNullable(input.nextString());
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new GetScriptSourceResponse(scriptSource, bytecode);
}
}
/**
* Returns source for the script with given id.
*/
public static Command getScriptSource(org.openqa.selenium.devtools.v85.runtime.model.ScriptId scriptId) {
java.util.Objects.requireNonNull(scriptId, "scriptId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("scriptId", scriptId);
return new Command<>("Debugger.getScriptSource", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v85.debugger.Debugger.GetScriptSourceResponse.class));
}
/**
* This command is deprecated. Use getScriptSource instead.
*/
@Deprecated()
public static Command getWasmBytecode(org.openqa.selenium.devtools.v85.runtime.model.ScriptId scriptId) {
java.util.Objects.requireNonNull(scriptId, "scriptId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("scriptId", scriptId);
return new Command<>("Debugger.getWasmBytecode", Map.copyOf(params), ConverterFunctions.map("bytecode", java.lang.String.class));
}
/**
* Returns stack trace with given `stackTraceId`.
*/
@Beta()
public static Command getStackTrace(org.openqa.selenium.devtools.v85.runtime.model.StackTraceId stackTraceId) {
java.util.Objects.requireNonNull(stackTraceId, "stackTraceId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("stackTraceId", stackTraceId);
return new Command<>("Debugger.getStackTrace", Map.copyOf(params), ConverterFunctions.map("stackTrace", org.openqa.selenium.devtools.v85.runtime.model.StackTrace.class));
}
/**
* Stops on the next JavaScript statement.
*/
public static Command pause() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Debugger.pause", Map.copyOf(params));
}
@Beta()
@Deprecated()
public static Command pauseOnAsyncCall(org.openqa.selenium.devtools.v85.runtime.model.StackTraceId parentStackTraceId) {
java.util.Objects.requireNonNull(parentStackTraceId, "parentStackTraceId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("parentStackTraceId", parentStackTraceId);
return new Command<>("Debugger.pauseOnAsyncCall", Map.copyOf(params));
}
/**
* Removes JavaScript breakpoint.
*/
public static Command removeBreakpoint(org.openqa.selenium.devtools.v85.debugger.model.BreakpointId breakpointId) {
java.util.Objects.requireNonNull(breakpointId, "breakpointId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("breakpointId", breakpointId);
return new Command<>("Debugger.removeBreakpoint", Map.copyOf(params));
}
public static class RestartFrameResponse {
private final java.util.List callFrames;
private final java.util.Optional asyncStackTrace;
private final java.util.Optional asyncStackTraceId;
public RestartFrameResponse(java.util.List callFrames, java.util.Optional asyncStackTrace, java.util.Optional asyncStackTraceId) {
this.callFrames = java.util.Objects.requireNonNull(callFrames, "callFrames is required");
this.asyncStackTrace = asyncStackTrace;
this.asyncStackTraceId = asyncStackTraceId;
}
/**
* New stack trace.
*/
public java.util.List getCallFrames() {
return callFrames;
}
/**
* Async stack trace, if any.
*/
public java.util.Optional getAsyncStackTrace() {
return asyncStackTrace;
}
/**
* Async stack trace, if any.
*/
public java.util.Optional getAsyncStackTraceId() {
return asyncStackTraceId;
}
private static RestartFrameResponse fromJson(JsonInput input) {
java.util.List callFrames = null;
java.util.Optional asyncStackTrace = java.util.Optional.empty();
java.util.Optional asyncStackTraceId = java.util.Optional.empty();
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "callFrames":
callFrames = input.readArray(org.openqa.selenium.devtools.v85.debugger.model.CallFrame.class);
break;
case "asyncStackTrace":
asyncStackTrace = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v85.runtime.model.StackTrace.class));
break;
case "asyncStackTraceId":
asyncStackTraceId = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v85.runtime.model.StackTraceId.class));
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new RestartFrameResponse(callFrames, asyncStackTrace, asyncStackTraceId);
}
}
/**
* Restarts particular call frame from the beginning.
*/
public static Command restartFrame(org.openqa.selenium.devtools.v85.debugger.model.CallFrameId callFrameId) {
java.util.Objects.requireNonNull(callFrameId, "callFrameId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("callFrameId", callFrameId);
return new Command<>("Debugger.restartFrame", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v85.debugger.Debugger.RestartFrameResponse.class));
}
/**
* Resumes JavaScript execution.
*/
public static Command resume(java.util.Optional terminateOnResume) {
LinkedHashMap params = new LinkedHashMap<>();
terminateOnResume.ifPresent(p -> params.put("terminateOnResume", p));
return new Command<>("Debugger.resume", Map.copyOf(params));
}
/**
* Searches for given string in script content.
*/
public static Command> searchInContent(org.openqa.selenium.devtools.v85.runtime.model.ScriptId scriptId, java.lang.String query, java.util.Optional caseSensitive, java.util.Optional isRegex) {
java.util.Objects.requireNonNull(scriptId, "scriptId is required");
java.util.Objects.requireNonNull(query, "query is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("scriptId", scriptId);
params.put("query", query);
caseSensitive.ifPresent(p -> params.put("caseSensitive", p));
isRegex.ifPresent(p -> params.put("isRegex", p));
return new Command<>("Debugger.searchInContent", Map.copyOf(params), ConverterFunctions.map("result", input -> input.readArray(org.openqa.selenium.devtools.v85.debugger.model.SearchMatch.class)));
}
/**
* Enables or disables async call stacks tracking.
*/
public static Command setAsyncCallStackDepth(java.lang.Integer maxDepth) {
java.util.Objects.requireNonNull(maxDepth, "maxDepth is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("maxDepth", maxDepth);
return new Command<>("Debugger.setAsyncCallStackDepth", Map.copyOf(params));
}
/**
* Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in
* scripts with url matching one of the patterns. VM will try to leave blackboxed script by
* performing 'step in' several times, finally resorting to 'step out' if unsuccessful.
*/
@Beta()
public static Command setBlackboxPatterns(java.util.List patterns) {
java.util.Objects.requireNonNull(patterns, "patterns is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("patterns", patterns);
return new Command<>("Debugger.setBlackboxPatterns", Map.copyOf(params));
}
/**
* Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted
* scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful.
* Positions array contains positions where blackbox state is changed. First interval isn't
* blackboxed. Array should be sorted.
*/
@Beta()
public static Command setBlackboxedRanges(org.openqa.selenium.devtools.v85.runtime.model.ScriptId scriptId, java.util.List positions) {
java.util.Objects.requireNonNull(scriptId, "scriptId is required");
java.util.Objects.requireNonNull(positions, "positions is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("scriptId", scriptId);
params.put("positions", positions);
return new Command<>("Debugger.setBlackboxedRanges", Map.copyOf(params));
}
public static class SetBreakpointResponse {
private final org.openqa.selenium.devtools.v85.debugger.model.BreakpointId breakpointId;
private final org.openqa.selenium.devtools.v85.debugger.model.Location actualLocation;
public SetBreakpointResponse(org.openqa.selenium.devtools.v85.debugger.model.BreakpointId breakpointId, org.openqa.selenium.devtools.v85.debugger.model.Location actualLocation) {
this.breakpointId = java.util.Objects.requireNonNull(breakpointId, "breakpointId is required");
this.actualLocation = java.util.Objects.requireNonNull(actualLocation, "actualLocation is required");
}
/**
* Id of the created breakpoint for further reference.
*/
public org.openqa.selenium.devtools.v85.debugger.model.BreakpointId getBreakpointId() {
return breakpointId;
}
/**
* Location this breakpoint resolved into.
*/
public org.openqa.selenium.devtools.v85.debugger.model.Location getActualLocation() {
return actualLocation;
}
private static SetBreakpointResponse fromJson(JsonInput input) {
org.openqa.selenium.devtools.v85.debugger.model.BreakpointId breakpointId = null;
org.openqa.selenium.devtools.v85.debugger.model.Location actualLocation = null;
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "breakpointId":
breakpointId = input.read(org.openqa.selenium.devtools.v85.debugger.model.BreakpointId.class);
break;
case "actualLocation":
actualLocation = input.read(org.openqa.selenium.devtools.v85.debugger.model.Location.class);
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new SetBreakpointResponse(breakpointId, actualLocation);
}
}
/**
* Sets JavaScript breakpoint at a given location.
*/
public static Command setBreakpoint(org.openqa.selenium.devtools.v85.debugger.model.Location location, java.util.Optional condition) {
java.util.Objects.requireNonNull(location, "location is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("location", location);
condition.ifPresent(p -> params.put("condition", p));
return new Command<>("Debugger.setBreakpoint", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v85.debugger.Debugger.SetBreakpointResponse.class));
}
public enum SetInstrumentationBreakpointInstrumentation {
BEFORESCRIPTEXECUTION("beforeScriptExecution"), BEFORESCRIPTWITHSOURCEMAPEXECUTION("beforeScriptWithSourceMapExecution");
private String value;
SetInstrumentationBreakpointInstrumentation(String value) {
this.value = value;
}
public static SetInstrumentationBreakpointInstrumentation fromString(String s) {
return java.util.Arrays.stream(SetInstrumentationBreakpointInstrumentation.values()).filter(rs -> rs.value.equalsIgnoreCase(s)).findFirst().orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException("Given value " + s + " is not found within SetInstrumentationBreakpointInstrumentation "));
}
public String toString() {
return value;
}
public String toJson() {
return value;
}
private static SetInstrumentationBreakpointInstrumentation fromJson(JsonInput input) {
return fromString(input.nextString());
}
}
/**
* Sets instrumentation breakpoint.
*/
public static Command setInstrumentationBreakpoint(SetInstrumentationBreakpointInstrumentation instrumentation) {
java.util.Objects.requireNonNull(instrumentation, "instrumentation is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("instrumentation", instrumentation);
return new Command<>("Debugger.setInstrumentationBreakpoint", Map.copyOf(params), ConverterFunctions.map("breakpointId", org.openqa.selenium.devtools.v85.debugger.model.BreakpointId.class));
}
public static class SetBreakpointByUrlResponse {
private final org.openqa.selenium.devtools.v85.debugger.model.BreakpointId breakpointId;
private final java.util.List locations;
public SetBreakpointByUrlResponse(org.openqa.selenium.devtools.v85.debugger.model.BreakpointId breakpointId, java.util.List locations) {
this.breakpointId = java.util.Objects.requireNonNull(breakpointId, "breakpointId is required");
this.locations = java.util.Objects.requireNonNull(locations, "locations is required");
}
/**
* Id of the created breakpoint for further reference.
*/
public org.openqa.selenium.devtools.v85.debugger.model.BreakpointId getBreakpointId() {
return breakpointId;
}
/**
* List of the locations this breakpoint resolved into upon addition.
*/
public java.util.List getLocations() {
return locations;
}
private static SetBreakpointByUrlResponse fromJson(JsonInput input) {
org.openqa.selenium.devtools.v85.debugger.model.BreakpointId breakpointId = null;
java.util.List locations = null;
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "breakpointId":
breakpointId = input.read(org.openqa.selenium.devtools.v85.debugger.model.BreakpointId.class);
break;
case "locations":
locations = input.readArray(org.openqa.selenium.devtools.v85.debugger.model.Location.class);
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new SetBreakpointByUrlResponse(breakpointId, locations);
}
}
/**
* Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this
* command is issued, all existing parsed scripts will have breakpoints resolved and returned in
* `locations` property. Further matching script parsing will result in subsequent
* `breakpointResolved` events issued. This logical breakpoint will survive page reloads.
*/
public static Command setBreakpointByUrl(java.lang.Integer lineNumber, java.util.Optional url, java.util.Optional urlRegex, java.util.Optional scriptHash, java.util.Optional columnNumber, java.util.Optional condition) {
java.util.Objects.requireNonNull(lineNumber, "lineNumber is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("lineNumber", lineNumber);
url.ifPresent(p -> params.put("url", p));
urlRegex.ifPresent(p -> params.put("urlRegex", p));
scriptHash.ifPresent(p -> params.put("scriptHash", p));
columnNumber.ifPresent(p -> params.put("columnNumber", p));
condition.ifPresent(p -> params.put("condition", p));
return new Command<>("Debugger.setBreakpointByUrl", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v85.debugger.Debugger.SetBreakpointByUrlResponse.class));
}
/**
* Sets JavaScript breakpoint before each call to the given function.
* If another function was created from the same source as a given one,
* calling it will also trigger the breakpoint.
*/
@Beta()
public static Command setBreakpointOnFunctionCall(org.openqa.selenium.devtools.v85.runtime.model.RemoteObjectId objectId, java.util.Optional condition) {
java.util.Objects.requireNonNull(objectId, "objectId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("objectId", objectId);
condition.ifPresent(p -> params.put("condition", p));
return new Command<>("Debugger.setBreakpointOnFunctionCall", Map.copyOf(params), ConverterFunctions.map("breakpointId", org.openqa.selenium.devtools.v85.debugger.model.BreakpointId.class));
}
/**
* Activates / deactivates all breakpoints on the page.
*/
public static Command setBreakpointsActive(java.lang.Boolean active) {
java.util.Objects.requireNonNull(active, "active is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("active", active);
return new Command<>("Debugger.setBreakpointsActive", Map.copyOf(params));
}
public enum SetPauseOnExceptionsState {
NONE("none"), UNCAUGHT("uncaught"), ALL("all");
private String value;
SetPauseOnExceptionsState(String value) {
this.value = value;
}
public static SetPauseOnExceptionsState fromString(String s) {
return java.util.Arrays.stream(SetPauseOnExceptionsState.values()).filter(rs -> rs.value.equalsIgnoreCase(s)).findFirst().orElseThrow(() -> new org.openqa.selenium.devtools.DevToolsException("Given value " + s + " is not found within SetPauseOnExceptionsState "));
}
public String toString() {
return value;
}
public String toJson() {
return value;
}
private static SetPauseOnExceptionsState fromJson(JsonInput input) {
return fromString(input.nextString());
}
}
/**
* Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or
* no exceptions. Initial pause on exceptions state is `none`.
*/
public static Command setPauseOnExceptions(SetPauseOnExceptionsState state) {
java.util.Objects.requireNonNull(state, "state is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("state", state);
return new Command<>("Debugger.setPauseOnExceptions", Map.copyOf(params));
}
/**
* Changes return value in top frame. Available only at return break position.
*/
@Beta()
public static Command setReturnValue(org.openqa.selenium.devtools.v85.runtime.model.CallArgument newValue) {
java.util.Objects.requireNonNull(newValue, "newValue is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("newValue", newValue);
return new Command<>("Debugger.setReturnValue", Map.copyOf(params));
}
public static class SetScriptSourceResponse {
private final java.util.Optional> callFrames;
private final java.util.Optional stackChanged;
private final java.util.Optional asyncStackTrace;
private final java.util.Optional asyncStackTraceId;
private final java.util.Optional exceptionDetails;
public SetScriptSourceResponse(java.util.Optional> callFrames, java.util.Optional stackChanged, java.util.Optional asyncStackTrace, java.util.Optional asyncStackTraceId, java.util.Optional exceptionDetails) {
this.callFrames = callFrames;
this.stackChanged = stackChanged;
this.asyncStackTrace = asyncStackTrace;
this.asyncStackTraceId = asyncStackTraceId;
this.exceptionDetails = exceptionDetails;
}
/**
* New stack trace in case editing has happened while VM was stopped.
*/
public java.util.Optional> getCallFrames() {
return callFrames;
}
/**
* Whether current call stack was modified after applying the changes.
*/
public java.util.Optional getStackChanged() {
return stackChanged;
}
/**
* Async stack trace, if any.
*/
public java.util.Optional getAsyncStackTrace() {
return asyncStackTrace;
}
/**
* Async stack trace, if any.
*/
public java.util.Optional getAsyncStackTraceId() {
return asyncStackTraceId;
}
/**
* Exception details if any.
*/
public java.util.Optional getExceptionDetails() {
return exceptionDetails;
}
private static SetScriptSourceResponse fromJson(JsonInput input) {
java.util.Optional> callFrames = java.util.Optional.empty();
java.util.Optional stackChanged = java.util.Optional.empty();
java.util.Optional asyncStackTrace = java.util.Optional.empty();
java.util.Optional asyncStackTraceId = java.util.Optional.empty();
java.util.Optional exceptionDetails = java.util.Optional.empty();
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "callFrames":
callFrames = java.util.Optional.ofNullable(input.readArray(org.openqa.selenium.devtools.v85.debugger.model.CallFrame.class));
break;
case "stackChanged":
stackChanged = java.util.Optional.ofNullable(input.nextBoolean());
break;
case "asyncStackTrace":
asyncStackTrace = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v85.runtime.model.StackTrace.class));
break;
case "asyncStackTraceId":
asyncStackTraceId = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v85.runtime.model.StackTraceId.class));
break;
case "exceptionDetails":
exceptionDetails = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v85.runtime.model.ExceptionDetails.class));
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new SetScriptSourceResponse(callFrames, stackChanged, asyncStackTrace, asyncStackTraceId, exceptionDetails);
}
}
/**
* Edits JavaScript source live.
*/
public static Command setScriptSource(org.openqa.selenium.devtools.v85.runtime.model.ScriptId scriptId, java.lang.String scriptSource, java.util.Optional dryRun) {
java.util.Objects.requireNonNull(scriptId, "scriptId is required");
java.util.Objects.requireNonNull(scriptSource, "scriptSource is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("scriptId", scriptId);
params.put("scriptSource", scriptSource);
dryRun.ifPresent(p -> params.put("dryRun", p));
return new Command<>("Debugger.setScriptSource", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v85.debugger.Debugger.SetScriptSourceResponse.class));
}
/**
* Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).
*/
public static Command setSkipAllPauses(java.lang.Boolean skip) {
java.util.Objects.requireNonNull(skip, "skip is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("skip", skip);
return new Command<>("Debugger.setSkipAllPauses", Map.copyOf(params));
}
/**
* Changes value of variable in a callframe. Object-based scopes are not supported and must be
* mutated manually.
*/
public static Command setVariableValue(java.lang.Integer scopeNumber, java.lang.String variableName, org.openqa.selenium.devtools.v85.runtime.model.CallArgument newValue, org.openqa.selenium.devtools.v85.debugger.model.CallFrameId callFrameId) {
java.util.Objects.requireNonNull(scopeNumber, "scopeNumber is required");
java.util.Objects.requireNonNull(variableName, "variableName is required");
java.util.Objects.requireNonNull(newValue, "newValue is required");
java.util.Objects.requireNonNull(callFrameId, "callFrameId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("scopeNumber", scopeNumber);
params.put("variableName", variableName);
params.put("newValue", newValue);
params.put("callFrameId", callFrameId);
return new Command<>("Debugger.setVariableValue", Map.copyOf(params));
}
/**
* Steps into the function call.
*/
public static Command stepInto(java.util.Optional breakOnAsyncCall) {
LinkedHashMap params = new LinkedHashMap<>();
breakOnAsyncCall.ifPresent(p -> params.put("breakOnAsyncCall", p));
return new Command<>("Debugger.stepInto", Map.copyOf(params));
}
/**
* Steps out of the function call.
*/
public static Command stepOut() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Debugger.stepOut", Map.copyOf(params));
}
/**
* Steps over the statement.
*/
public static Command stepOver() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Debugger.stepOver", Map.copyOf(params));
}
public static Event breakpointResolved() {
return new Event<>("Debugger.breakpointResolved", input -> input.read(org.openqa.selenium.devtools.v85.debugger.model.BreakpointResolved.class));
}
public static Event paused() {
return new Event<>("Debugger.paused", input -> input.read(org.openqa.selenium.devtools.v85.debugger.model.Paused.class));
}
public static Event resumed() {
return new Event<>("Debugger.resumed", ConverterFunctions.empty());
}
public static Event scriptFailedToParse() {
return new Event<>("Debugger.scriptFailedToParse", input -> input.read(org.openqa.selenium.devtools.v85.debugger.model.ScriptFailedToParse.class));
}
public static Event scriptParsed() {
return new Event<>("Debugger.scriptParsed", input -> input.read(org.openqa.selenium.devtools.v85.debugger.model.ScriptParsed.class));
}
}