← Back to Runtime domain

Runtime.runScript

Runs script with given id in a given context.

Domain: Runtime stable

Parameters

NameTypeDescription
scriptIdScriptIdId of the script to run.
executionContextId (optional)ExecutionContextIdSpecifies in which execution context to perform script run. If the parameter is omitted the evaluation will be performed in the context of the inspected page.
objectGroup (optional)stringSymbolic group name that can be used to release multiple objects.
silent (optional)booleanIn silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides `setPauseOnException` state.
includeCommandLineAPI (optional)booleanDetermines whether Command Line API should be available during the evaluation.
returnByValue (optional)booleanWhether the result is expected to be a JSON object which should be sent by value.
generatePreview (optional)booleanWhether preview should be generated for the result.
awaitPromise (optional)booleanWhether execution should `await` for resulting value and return once awaited promise is resolved.

Returns

NameTypeDescription
resultRemoteObjectRun result.
exceptionDetailsExceptionDetailsException details.

Example Request

{
  "id": 1,
  "method": "Runtime.runScript",
  "params": {
    "scriptId": "1"
  }
}

Example Response

{
  "id": 1,
  "result": {
    "result": {
      "type": "string",
      "value": "Example Domain"
    },
    "exceptionDetails": "exceptionDetails-value"
  }
}

Usage in Node.js

const result = await send('Runtime.runScript', {"scriptId": "1"});
console.log(result);
// {"result": {"type": "string", "value": "Example Domain"}, "exceptionDetails": "exceptionDetails-value"}