← Back to Runtime domain
Runtime.runScript
Runs script with given id in a given context.
Domain: Runtime
stable
Parameters
| Name | Type | Description |
scriptId | ScriptId | Id of the script to run. |
executionContextId (optional) | ExecutionContextId | Specifies 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) | string | Symbolic group name that can be used to release multiple objects. |
silent (optional) | boolean | In silent mode exceptions thrown during evaluation are not reported and do not pause
execution. Overrides `setPauseOnException` state. |
includeCommandLineAPI (optional) | boolean | Determines whether Command Line API should be available during the evaluation. |
returnByValue (optional) | boolean | Whether the result is expected to be a JSON object which should be sent by value. |
generatePreview (optional) | boolean | Whether preview should be generated for the result. |
awaitPromise (optional) | boolean | Whether execution should `await` for resulting value and return once awaited promise is
resolved. |
Returns
| Name | Type | Description |
result | RemoteObject | Run result. |
exceptionDetails | ExceptionDetails | Exception 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"}