The browser.close command of the browser module closes the browser and ends all active WebDriver sessions. Tabs are closed without running beforeunload event handler functions. The response is sent before the WebSocket connection is closed.
Syntax
{
"method": "browser.close",
"params": {}
}
Parameters
None. However, you must include the params field and set it to an empty object ({}).
Return value
The result field in the response is an empty object ({}).
Errors
unable to close browser- : There are other active WebDriver sessions open at the time the command is sent. Browsers may return this error before continuing to close.
Examples
Closing the browser
With a WebDriver BiDi connection and an active session, send the following message to close the browser:
{
"id": 1,
"method": "browser.close",
"params": {}
}
Before closing, the browser responds successfully as shown here:
{
"id": 1,
"type": "success",
"result": {}
}
After the response, the WebSocket connection closes as the browser shuts down.
Specifications
Browser compatibility
See also
session.newcommandsession.endcommandbrowser.createUserContextcommandbrowser.getUserContextscommandbrowser.removeUserContextcommand
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
