大网数据广告活动
Web 标准与前端开发

`browser.close` command

· 52CE 我爱测

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.

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

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。