script.removePreloadScript command
The script.removePreloadScript command of the script module removes the specified preload script.
Syntax
/* With required parameters */
{
"method": "script.removePreloadScript",
"params": {
"script": "d4b1a0f6-2a3c-4f7d-9e21-5c6b7a8d9e0f"
}
}
Parameters
The params field contains:
script-
A string that contains the UUID of the preload script to remove. Preload script IDs are returned by the
script.addPreloadScriptcommand.
Return value
The result field in the response is an empty object ({}).
Errors
invalid argument-
Thrown if a required parameter is missing or has an invalid type.
no such script-
Thrown if no preload script with the specified script ID is found.
Description
After a preload script is removed, the browser no longer runs it in new documents. Removing a preload script does not undo changes it has already made.
When a session ends, the browser automatically removes all preload scripts registered in that session.
Examples
>Removing a preload script
Assume you have a WebDriver BiDi connection and an active session.
Suppose you registered a preload script that logs each new document's URL by using script.addPreloadScript.
The browser returns the preload script's ID in the script field.
To stop logging URLs for new documents, send the following message to remove the preload script:
{
"id": 3,
"method": "script.removePreloadScript",
"params": {
"script": "d4b1a0f6-2a3c-4f7d-9e21-5c6b7a8d9e0f"
}
}
The browser responds with an empty result object:
{
"id": 3,
"type": "success",
"result": {}
}
When you subsequently navigate a context to a new document, the removed preload script no longer logs the document's URL.
Specifications
| Specification |
|---|
| WebDriver BiDi> # command-script-removePreloadScript> |
Browser compatibility
See also
script.addPreloadScriptcommandscript.evaluatecommandscript.callFunctioncommand