browser.close command

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

json
{
  "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:

json
{
  "id": 1,
  "method": "browser.close",
  "params": {}
}

Before closing, the browser responds successfully as shown here:

json
{
  "id": 1,
  "type": "success",
  "result": {}
}

After the response, the WebSocket connection closes as the browser shuts down.

Specifications

Specification
WebDriver BiDi
# command-browser-close

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
browser.close command
Chrome – Full support
Chrome 126 (Release date: 2024-06-11)
footnote Full support
Edge – Full support
Edge 126 (Release date: 2024-06-13)
footnote Full support
Firefox – Full support
Firefox 117 (Release date: 2023-08-29)
footnote
footnote Before Firefox 129, beforeunload prompts could not be skipped.
Opera – Full support
Opera 112 (Release date: 2024-07-11)
footnote Full support
Safari – No support
Safari
footnote
footnote See bug 288103
Chrome Android – Full support
Chrome Android 126 (Release date: 2024-06-11)
footnote Full support
Firefox for Android – Full support
Firefox for Android 117 (Release date: 2023-08-29)
footnote
footnote Before Firefox for Android 129, beforeunload prompts could not be skipped.
Opera Android – Full support
Opera Android 83 (Release date: 2024-06-25)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 288103
Samsung Internet – Full support
Samsung Internet 28 (Release date: 2025-04-02)
footnote Full support
WebView Android – Full support
WebView Android 126 (Release date: 2024-06-11)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 288103

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

See also