Class Runtime


  • public class Runtime
    extends java.lang.Object
    Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects. Evaluation results are returned as mirror object that expose object type, string representation and unique identifier that can be used for further object reference. Original objects are maintained in memory unless they are either explicitly released or are released along with the other objects in their object group.
    • Constructor Summary

      Constructors 
      Constructor Description
      Runtime()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.openqa.selenium.devtools.Command<java.lang.Void> addBinding​(java.lang.String name, java.util.Optional<ExecutionContextId> executionContextId)
      If executionContextId is empty, adds binding with the given name on the global objects of all inspected contexts, including those created later, bindings survive reloads.
      static org.openqa.selenium.devtools.Command<Runtime.AwaitPromiseResponse> awaitPromise​(RemoteObjectId promiseObjectId, java.util.Optional<java.lang.Boolean> returnByValue, java.util.Optional<java.lang.Boolean> generatePreview)
      Add handler to promise with given promise object id.
      static org.openqa.selenium.devtools.Event<BindingCalled> bindingCalled()  
      static org.openqa.selenium.devtools.Command<Runtime.CallFunctionOnResponse> callFunctionOn​(java.lang.String functionDeclaration, java.util.Optional<RemoteObjectId> objectId, java.util.Optional<java.util.List<CallArgument>> arguments, 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> userGesture, java.util.Optional<java.lang.Boolean> awaitPromise, java.util.Optional<ExecutionContextId> executionContextId, java.util.Optional<java.lang.String> objectGroup)
      Calls function with given declaration on the given object.
      static org.openqa.selenium.devtools.Command<Runtime.CompileScriptResponse> compileScript​(java.lang.String expression, java.lang.String sourceURL, java.lang.Boolean persistScript, java.util.Optional<ExecutionContextId> executionContextId)
      Compiles expression.
      static org.openqa.selenium.devtools.Event<ConsoleAPICalled> consoleAPICalled()  
      static org.openqa.selenium.devtools.Command<java.lang.Void> disable()
      Disables reporting of execution contexts creation.
      static org.openqa.selenium.devtools.Command<java.lang.Void> discardConsoleEntries()
      Discards collected exceptions and console API calls.
      static org.openqa.selenium.devtools.Command<java.lang.Void> enable()
      Enables reporting of execution contexts creation by means of `executionContextCreated` event.
      static org.openqa.selenium.devtools.Command<Runtime.EvaluateResponse> evaluate​(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<ExecutionContextId> contextId, java.util.Optional<java.lang.Boolean> returnByValue, java.util.Optional<java.lang.Boolean> generatePreview, java.util.Optional<java.lang.Boolean> userGesture, java.util.Optional<java.lang.Boolean> awaitPromise, java.util.Optional<java.lang.Boolean> throwOnSideEffect, java.util.Optional<TimeDelta> timeout, java.util.Optional<java.lang.Boolean> disableBreaks, java.util.Optional<java.lang.Boolean> replMode, java.util.Optional<java.lang.Boolean> allowUnsafeEvalBlockedByCSP)
      Evaluates expression on global object.
      static org.openqa.selenium.devtools.Event<ExceptionRevoked> exceptionRevoked()  
      static org.openqa.selenium.devtools.Event<ExceptionThrown> exceptionThrown()  
      static org.openqa.selenium.devtools.Event<ExecutionContextDescription> executionContextCreated()  
      static org.openqa.selenium.devtools.Event<ExecutionContextId> executionContextDestroyed()  
      static org.openqa.selenium.devtools.Event<java.lang.Void> executionContextsCleared()  
      static org.openqa.selenium.devtools.Command<Runtime.GetHeapUsageResponse> getHeapUsage()
      Returns the JavaScript heap usage.
      static org.openqa.selenium.devtools.Command<java.lang.String> getIsolateId()
      Returns the isolate id.
      static org.openqa.selenium.devtools.Command<Runtime.GetPropertiesResponse> getProperties​(RemoteObjectId objectId, java.util.Optional<java.lang.Boolean> ownProperties, java.util.Optional<java.lang.Boolean> accessorPropertiesOnly, java.util.Optional<java.lang.Boolean> generatePreview)
      Returns properties of a given object.
      static org.openqa.selenium.devtools.Command<java.util.List<java.lang.String>> globalLexicalScopeNames​(java.util.Optional<ExecutionContextId> executionContextId)
      Returns all let, const and class variables from global scope.
      static org.openqa.selenium.devtools.Event<InspectRequested> inspectRequested()  
      static org.openqa.selenium.devtools.Command<RemoteObject> queryObjects​(RemoteObjectId prototypeObjectId, java.util.Optional<java.lang.String> objectGroup)  
      static org.openqa.selenium.devtools.Command<java.lang.Void> releaseObject​(RemoteObjectId objectId)
      Releases remote object with given id.
      static org.openqa.selenium.devtools.Command<java.lang.Void> releaseObjectGroup​(java.lang.String objectGroup)
      Releases all remote objects that belong to a given group.
      static org.openqa.selenium.devtools.Command<java.lang.Void> removeBinding​(java.lang.String name)
      This method does not remove binding function from global object but unsubscribes current runtime agent from Runtime.bindingCalled notifications.
      static org.openqa.selenium.devtools.Command<java.lang.Void> runIfWaitingForDebugger()
      Tells inspected instance to run if it was waiting for debugger to attach.
      static org.openqa.selenium.devtools.Command<Runtime.RunScriptResponse> runScript​(ScriptId scriptId, java.util.Optional<ExecutionContextId> executionContextId, java.util.Optional<java.lang.String> objectGroup, java.util.Optional<java.lang.Boolean> silent, java.util.Optional<java.lang.Boolean> includeCommandLineAPI, java.util.Optional<java.lang.Boolean> returnByValue, java.util.Optional<java.lang.Boolean> generatePreview, java.util.Optional<java.lang.Boolean> awaitPromise)
      Runs script with given id in a given context.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setAsyncCallStackDepth​(java.lang.Integer maxDepth)
      Enables or disables async call stacks tracking.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setCustomObjectFormatterEnabled​(java.lang.Boolean enabled)  
      static org.openqa.selenium.devtools.Command<java.lang.Void> setMaxCallStackSizeToCapture​(java.lang.Integer size)  
      static org.openqa.selenium.devtools.Command<java.lang.Void> terminateExecution()
      Terminate current or next JavaScript execution.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Runtime

        public Runtime()
    • Method Detail

      • awaitPromise

        public static org.openqa.selenium.devtools.Command<Runtime.AwaitPromiseResponse> awaitPromise​(RemoteObjectId promiseObjectId,
                                                                                                      java.util.Optional<java.lang.Boolean> returnByValue,
                                                                                                      java.util.Optional<java.lang.Boolean> generatePreview)
        Add handler to promise with given promise object id.
      • callFunctionOn

        public static org.openqa.selenium.devtools.Command<Runtime.CallFunctionOnResponse> callFunctionOn​(java.lang.String functionDeclaration,
                                                                                                          java.util.Optional<RemoteObjectId> objectId,
                                                                                                          java.util.Optional<java.util.List<CallArgument>> arguments,
                                                                                                          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> userGesture,
                                                                                                          java.util.Optional<java.lang.Boolean> awaitPromise,
                                                                                                          java.util.Optional<ExecutionContextId> executionContextId,
                                                                                                          java.util.Optional<java.lang.String> objectGroup)
        Calls function with given declaration on the given object. Object group of the result is inherited from the target object.
      • compileScript

        public static org.openqa.selenium.devtools.Command<Runtime.CompileScriptResponse> compileScript​(java.lang.String expression,
                                                                                                        java.lang.String sourceURL,
                                                                                                        java.lang.Boolean persistScript,
                                                                                                        java.util.Optional<ExecutionContextId> executionContextId)
        Compiles expression.
      • disable

        public static org.openqa.selenium.devtools.Command<java.lang.Void> disable()
        Disables reporting of execution contexts creation.
      • discardConsoleEntries

        public static org.openqa.selenium.devtools.Command<java.lang.Void> discardConsoleEntries()
        Discards collected exceptions and console API calls.
      • enable

        public static org.openqa.selenium.devtools.Command<java.lang.Void> enable()
        Enables reporting of execution contexts creation by means of `executionContextCreated` event. When the reporting gets enabled the event will be sent immediately for each existing execution context.
      • evaluate

        public static org.openqa.selenium.devtools.Command<Runtime.EvaluateResponse> evaluate​(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<ExecutionContextId> contextId,
                                                                                              java.util.Optional<java.lang.Boolean> returnByValue,
                                                                                              java.util.Optional<java.lang.Boolean> generatePreview,
                                                                                              java.util.Optional<java.lang.Boolean> userGesture,
                                                                                              java.util.Optional<java.lang.Boolean> awaitPromise,
                                                                                              java.util.Optional<java.lang.Boolean> throwOnSideEffect,
                                                                                              java.util.Optional<TimeDelta> timeout,
                                                                                              java.util.Optional<java.lang.Boolean> disableBreaks,
                                                                                              java.util.Optional<java.lang.Boolean> replMode,
                                                                                              java.util.Optional<java.lang.Boolean> allowUnsafeEvalBlockedByCSP)
        Evaluates expression on global object.
      • getIsolateId

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.String> getIsolateId()
        Returns the isolate id.
      • getHeapUsage

        @Beta
        public static org.openqa.selenium.devtools.Command<Runtime.GetHeapUsageResponse> getHeapUsage()
        Returns the JavaScript heap usage. It is the total usage of the corresponding isolate not scoped to a particular Runtime.
      • getProperties

        public static org.openqa.selenium.devtools.Command<Runtime.GetPropertiesResponse> getProperties​(RemoteObjectId objectId,
                                                                                                        java.util.Optional<java.lang.Boolean> ownProperties,
                                                                                                        java.util.Optional<java.lang.Boolean> accessorPropertiesOnly,
                                                                                                        java.util.Optional<java.lang.Boolean> generatePreview)
        Returns properties of a given object. Object group of the result is inherited from the target object.
      • globalLexicalScopeNames

        public static org.openqa.selenium.devtools.Command<java.util.List<java.lang.String>> globalLexicalScopeNames​(java.util.Optional<ExecutionContextId> executionContextId)
        Returns all let, const and class variables from global scope.
      • queryObjects

        public static org.openqa.selenium.devtools.Command<RemoteObject> queryObjects​(RemoteObjectId prototypeObjectId,
                                                                                      java.util.Optional<java.lang.String> objectGroup)
      • releaseObject

        public static org.openqa.selenium.devtools.Command<java.lang.Void> releaseObject​(RemoteObjectId objectId)
        Releases remote object with given id.
      • releaseObjectGroup

        public static org.openqa.selenium.devtools.Command<java.lang.Void> releaseObjectGroup​(java.lang.String objectGroup)
        Releases all remote objects that belong to a given group.
      • runIfWaitingForDebugger

        public static org.openqa.selenium.devtools.Command<java.lang.Void> runIfWaitingForDebugger()
        Tells inspected instance to run if it was waiting for debugger to attach.
      • runScript

        public static org.openqa.selenium.devtools.Command<Runtime.RunScriptResponse> runScript​(ScriptId scriptId,
                                                                                                java.util.Optional<ExecutionContextId> executionContextId,
                                                                                                java.util.Optional<java.lang.String> objectGroup,
                                                                                                java.util.Optional<java.lang.Boolean> silent,
                                                                                                java.util.Optional<java.lang.Boolean> includeCommandLineAPI,
                                                                                                java.util.Optional<java.lang.Boolean> returnByValue,
                                                                                                java.util.Optional<java.lang.Boolean> generatePreview,
                                                                                                java.util.Optional<java.lang.Boolean> awaitPromise)
        Runs script with given id in a given context.
      • setAsyncCallStackDepth

        public static org.openqa.selenium.devtools.Command<java.lang.Void> setAsyncCallStackDepth​(java.lang.Integer maxDepth)
        Enables or disables async call stacks tracking.
      • setCustomObjectFormatterEnabled

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setCustomObjectFormatterEnabled​(java.lang.Boolean enabled)
      • setMaxCallStackSizeToCapture

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setMaxCallStackSizeToCapture​(java.lang.Integer size)
      • terminateExecution

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> terminateExecution()
        Terminate current or next JavaScript execution. Will cancel the termination when the outer-most script execution ends.
      • addBinding

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> addBinding​(java.lang.String name,
                                                                                      java.util.Optional<ExecutionContextId> executionContextId)
        If executionContextId is empty, adds binding with the given name on the global objects of all inspected contexts, including those created later, bindings survive reloads. If executionContextId is specified, adds binding only on global object of given execution context. Binding function takes exactly one argument, this argument should be string, in case of any other input, function throws an exception. Each binding function call produces Runtime.bindingCalled notification.
      • removeBinding

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> removeBinding​(java.lang.String name)
        This method does not remove binding function from global object but unsubscribes current runtime agent from Runtime.bindingCalled notifications.
      • bindingCalled

        public static org.openqa.selenium.devtools.Event<BindingCalled> bindingCalled()
      • consoleAPICalled

        public static org.openqa.selenium.devtools.Event<ConsoleAPICalled> consoleAPICalled()
      • exceptionRevoked

        public static org.openqa.selenium.devtools.Event<ExceptionRevoked> exceptionRevoked()
      • exceptionThrown

        public static org.openqa.selenium.devtools.Event<ExceptionThrown> exceptionThrown()
      • executionContextDestroyed

        public static org.openqa.selenium.devtools.Event<ExecutionContextId> executionContextDestroyed()
      • executionContextsCleared

        public static org.openqa.selenium.devtools.Event<java.lang.Void> executionContextsCleared()
      • inspectRequested

        public static org.openqa.selenium.devtools.Event<InspectRequested> inspectRequested()