Class Debugger
- java.lang.Object
-
- org.openqa.selenium.devtools.debugger.Debugger
-
public class Debugger extends java.lang.Object
Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Debugger.ContinueToLocationTargetCallFrames
static class
Debugger.EvaluateOnCallFrameResponse
static class
Debugger.RestartFrameResponse
static class
Debugger.SetBreakpointByUrlResponse
static class
Debugger.SetBreakpointResponse
static class
Debugger.SetInstrumentationBreakpointInstrumentation
static class
Debugger.SetPauseOnExceptionsState
static class
Debugger.SetScriptSourceResponse
-
Constructor Summary
Constructors Constructor Description Debugger()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Event<BreakpointResolved>
breakpointResolved()
static Command<java.lang.Void>
continueToLocation(Location location, java.util.Optional<Debugger.ContinueToLocationTargetCallFrames> targetCallFrames)
Continues execution until specific location is reached.static Command<java.lang.Void>
disable()
Disables debugger for given page.static Command<UniqueDebuggerId>
enable(java.util.Optional<java.lang.Number> maxScriptsCacheSize)
Enables debugger for the given page.static Command<Debugger.EvaluateOnCallFrameResponse>
evaluateOnCallFrame(CallFrameId callFrameId, java.lang.String expression, java.util.Optional<java.lang.String> objectGroup, java.util.Optional<java.lang.Boolean> includeCommandLineAPI, java.util.Optional<java.lang.Boolean> silent, java.util.Optional<java.lang.Boolean> returnByValue, java.util.Optional<java.lang.Boolean> generatePreview, java.util.Optional<java.lang.Boolean> throwOnSideEffect, java.util.Optional<TimeDelta> timeout)
Evaluates expression on a given call frame.static Command<java.util.List<BreakLocation>>
getPossibleBreakpoints(Location start, java.util.Optional<Location> end, java.util.Optional<java.lang.Boolean> restrictToFunction)
Returns possible locations for breakpoint.static Command<java.lang.String>
getScriptSource(ScriptId scriptId)
Returns source for the script with given id.static Command<StackTrace>
getStackTrace(StackTraceId stackTraceId)
Returns stack trace with given `stackTraceId`.static Command<java.lang.Void>
pause()
Stops on the next JavaScript statement.static Event<Paused>
paused()
static Command<java.lang.Void>
pauseOnAsyncCall(StackTraceId parentStackTraceId)
static Command<java.lang.Void>
removeBreakpoint(BreakpointId breakpointId)
Removes JavaScript breakpoint.static Command<Debugger.RestartFrameResponse>
restartFrame(CallFrameId callFrameId)
Restarts particular call frame from the beginning.static Command<java.lang.Void>
resume()
Resumes JavaScript execution.static Event<java.lang.Void>
resumed()
static Event<ScriptFailedToParse>
scriptFailedToParse()
static Event<ScriptParsed>
scriptParsed()
static Command<java.util.List<SearchMatch>>
searchInContent(ScriptId scriptId, java.lang.String query, java.util.Optional<java.lang.Boolean> caseSensitive, java.util.Optional<java.lang.Boolean> isRegex)
Searches for given string in script content.static Command<java.lang.Void>
setAsyncCallStackDepth(java.lang.Integer maxDepth)
Enables or disables async call stacks tracking.static Command<java.lang.Void>
setBlackboxedRanges(ScriptId scriptId, java.util.List<ScriptPosition> positions)
Makes backend skip steps in the script in blackboxed ranges.static Command<java.lang.Void>
setBlackboxPatterns(java.util.List<java.lang.String> patterns)
Replace previous blackbox patterns with passed ones.static Command<Debugger.SetBreakpointResponse>
setBreakpoint(Location location, java.util.Optional<java.lang.String> condition)
Sets JavaScript breakpoint at a given location.static Command<Debugger.SetBreakpointByUrlResponse>
setBreakpointByUrl(java.lang.Integer lineNumber, java.util.Optional<java.lang.String> url, java.util.Optional<java.lang.String> urlRegex, java.util.Optional<java.lang.String> scriptHash, java.util.Optional<java.lang.Integer> columnNumber, java.util.Optional<java.lang.String> condition)
Sets JavaScript breakpoint at given location specified either by URL or URL regex.static Command<BreakpointId>
setBreakpointOnFunctionCall(RemoteObjectId objectId, java.util.Optional<java.lang.String> condition)
Sets JavaScript breakpoint before each call to the given function.static Command<java.lang.Void>
setBreakpointsActive(java.lang.Boolean active)
Activates / deactivates all breakpoints on the page.static Command<BreakpointId>
setInstrumentationBreakpoint(Debugger.SetInstrumentationBreakpointInstrumentation instrumentation)
Sets instrumentation breakpoint.static Command<java.lang.Void>
setPauseOnExceptions(Debugger.SetPauseOnExceptionsState state)
Defines pause on exceptions state.static Command<java.lang.Void>
setReturnValue(CallArgument newValue)
Changes return value in top frame.static Command<Debugger.SetScriptSourceResponse>
setScriptSource(ScriptId scriptId, java.lang.String scriptSource, java.util.Optional<java.lang.Boolean> dryRun)
Edits JavaScript source live.static Command<java.lang.Void>
setSkipAllPauses(java.lang.Boolean skip)
Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).static Command<java.lang.Void>
setVariableValue(java.lang.Integer scopeNumber, java.lang.String variableName, CallArgument newValue, CallFrameId callFrameId)
Changes value of variable in a callframe.static Command<java.lang.Void>
stepInto(java.util.Optional<java.lang.Boolean> breakOnAsyncCall)
Steps into the function call.static Command<java.lang.Void>
stepOut()
Steps out of the function call.static Command<java.lang.Void>
stepOver()
Steps over the statement.
-
-
-
Method Detail
-
continueToLocation
public static Command<java.lang.Void> continueToLocation(Location location, java.util.Optional<Debugger.ContinueToLocationTargetCallFrames> targetCallFrames)
Continues execution until specific location is reached.
-
disable
public static Command<java.lang.Void> disable()
Disables debugger for given page.
-
enable
public static Command<UniqueDebuggerId> enable(java.util.Optional<java.lang.Number> maxScriptsCacheSize)
Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.
-
evaluateOnCallFrame
public static Command<Debugger.EvaluateOnCallFrameResponse> evaluateOnCallFrame(CallFrameId callFrameId, java.lang.String expression, java.util.Optional<java.lang.String> objectGroup, java.util.Optional<java.lang.Boolean> includeCommandLineAPI, java.util.Optional<java.lang.Boolean> silent, java.util.Optional<java.lang.Boolean> returnByValue, java.util.Optional<java.lang.Boolean> generatePreview, java.util.Optional<java.lang.Boolean> throwOnSideEffect, java.util.Optional<TimeDelta> timeout)
Evaluates expression on a given call frame.
-
getPossibleBreakpoints
public static Command<java.util.List<BreakLocation>> getPossibleBreakpoints(Location start, java.util.Optional<Location> end, java.util.Optional<java.lang.Boolean> restrictToFunction)
Returns possible locations for breakpoint. scriptId in start and end range locations should be the same.
-
getScriptSource
public static Command<java.lang.String> getScriptSource(ScriptId scriptId)
Returns source for the script with given id.
-
getStackTrace
@Beta public static Command<StackTrace> getStackTrace(StackTraceId stackTraceId)
Returns stack trace with given `stackTraceId`.
-
pause
public static Command<java.lang.Void> pause()
Stops on the next JavaScript statement.
-
pauseOnAsyncCall
@Beta public static Command<java.lang.Void> pauseOnAsyncCall(StackTraceId parentStackTraceId)
-
removeBreakpoint
public static Command<java.lang.Void> removeBreakpoint(BreakpointId breakpointId)
Removes JavaScript breakpoint.
-
restartFrame
public static Command<Debugger.RestartFrameResponse> restartFrame(CallFrameId callFrameId)
Restarts particular call frame from the beginning.
-
resume
public static Command<java.lang.Void> resume()
Resumes JavaScript execution.
-
searchInContent
public static Command<java.util.List<SearchMatch>> searchInContent(ScriptId scriptId, java.lang.String query, java.util.Optional<java.lang.Boolean> caseSensitive, java.util.Optional<java.lang.Boolean> isRegex)
Searches for given string in script content.
-
setAsyncCallStackDepth
public static Command<java.lang.Void> setAsyncCallStackDepth(java.lang.Integer maxDepth)
Enables or disables async call stacks tracking.
-
setBlackboxPatterns
@Beta public static Command<java.lang.Void> setBlackboxPatterns(java.util.List<java.lang.String> patterns)
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.
-
setBlackboxedRanges
@Beta public static Command<java.lang.Void> setBlackboxedRanges(ScriptId scriptId, java.util.List<ScriptPosition> positions)
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.
-
setBreakpoint
public static Command<Debugger.SetBreakpointResponse> setBreakpoint(Location location, java.util.Optional<java.lang.String> condition)
Sets JavaScript breakpoint at a given location.
-
setInstrumentationBreakpoint
public static Command<BreakpointId> setInstrumentationBreakpoint(Debugger.SetInstrumentationBreakpointInstrumentation instrumentation)
Sets instrumentation breakpoint.
-
setBreakpointByUrl
public static Command<Debugger.SetBreakpointByUrlResponse> setBreakpointByUrl(java.lang.Integer lineNumber, java.util.Optional<java.lang.String> url, java.util.Optional<java.lang.String> urlRegex, java.util.Optional<java.lang.String> scriptHash, java.util.Optional<java.lang.Integer> columnNumber, java.util.Optional<java.lang.String> condition)
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.
-
setBreakpointOnFunctionCall
@Beta public static Command<BreakpointId> setBreakpointOnFunctionCall(RemoteObjectId objectId, java.util.Optional<java.lang.String> condition)
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.
-
setBreakpointsActive
public static Command<java.lang.Void> setBreakpointsActive(java.lang.Boolean active)
Activates / deactivates all breakpoints on the page.
-
setPauseOnExceptions
public static Command<java.lang.Void> setPauseOnExceptions(Debugger.SetPauseOnExceptionsState state)
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`.
-
setReturnValue
@Beta public static Command<java.lang.Void> setReturnValue(CallArgument newValue)
Changes return value in top frame. Available only at return break position.
-
setScriptSource
public static Command<Debugger.SetScriptSourceResponse> setScriptSource(ScriptId scriptId, java.lang.String scriptSource, java.util.Optional<java.lang.Boolean> dryRun)
Edits JavaScript source live.
-
setSkipAllPauses
public static Command<java.lang.Void> setSkipAllPauses(java.lang.Boolean skip)
Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).
-
setVariableValue
public static Command<java.lang.Void> setVariableValue(java.lang.Integer scopeNumber, java.lang.String variableName, CallArgument newValue, CallFrameId callFrameId)
Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually.
-
stepInto
public static Command<java.lang.Void> stepInto(java.util.Optional<java.lang.Boolean> breakOnAsyncCall)
Steps into the function call.
-
stepOut
public static Command<java.lang.Void> stepOut()
Steps out of the function call.
-
stepOver
public static Command<java.lang.Void> stepOver()
Steps over the statement.
-
breakpointResolved
public static Event<BreakpointResolved> breakpointResolved()
-
resumed
public static Event<java.lang.Void> resumed()
-
scriptFailedToParse
public static Event<ScriptFailedToParse> scriptFailedToParse()
-
scriptParsed
public static Event<ScriptParsed> scriptParsed()
-
-