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

`browser.getClientWindows` command

· 52CE 我爱测

The `browser.getClientWindows` command of the `browser` module returns a list of client windows.

The browser.getClientWindows command of the browser module returns a list of client windows.

Syntax

{
  "method": "browser.getClientWindows",
  "params": {}
}

Parameters

None. However, you must include the params field and set it to an empty object ({}).

Return value

The following field in the result object of the response describes the client windows in the browser:

  • clientWindows
    • : An array of objects, each representing a client window. The array may be empty if the browser has no open windows. Each object has the following fields:
      • active
        • : A boolean that indicates whether the client window can receive keyboard input from the operating system. This can mean a tab within the window has system focus, or the browser UI itself is focused.
      • clientWindow
        • : A string that uniquely identifies the client window.
      • height
        • : A number that indicates the height of the window in CSS pixel.
      • state
        • : A string that indicates the current state of the window.
          • "fullscreen"
            • : Indicates that the window is in fullscreen mode.
          • "maximized"
            • : Indicates that the window is maximized to fill the screen area.
          • "minimized"
            • : Indicates that the window is minimized (hidden from view).
          • "normal"
            • : Indicates that the window is in its normal (restored) state.
      • width
        • : A number that indicates the width of the window in CSS pixel.
      • x
        • : A number that indicates the x-coordinate of the window in CSS pixel, measured from the left edge of the screen area.
      • y
        • : A number that indicates the y-coordinate of the window in CSS pixel, measured from the top edge of the screen area.

Examples

Getting all client windows

With a WebDriver BiDi connection and an active session, send the following message to retrieve all client windows:

{
  "id": 1,
  "method": "browser.getClientWindows",
  "params": {}
}

The browser responds successfully with the list of client windows as follows:

{
  "id": 1,
  "type": "success",
  "result": {
    "clientWindows": [
      {
        "active": true,
        "clientWindow": "09a7bf22-c52d-4011-88ad-507a7e0012c7",
        "height": 970,
        "state": "normal",
        "width": 1280,
        "x": 4,
        "y": 38
      }
    ]
  }
}

Getting client windows when multiple browser windows are open

When multiple browser windows are open, the browser responds with one entry per window as follows:

{
  "id": 2,
  "type": "success",
  "result": {
    "clientWindows": [
      {
        "active": true,
        "clientWindow": "09a7bf22-c52d-4011-88ad-507a7e0012c7",
        "height": 800,
        "state": "normal",
        "width": 1280,
        "x": 0,
        "y": 26
      },
      {
        "active": false,
        "clientWindow": "b3f8a1e5-d4c2-4e9f-8b3a-1f2e3d4c5b6a",
        "height": 0,
        "state": "minimized",
        "width": 0,
        "x": 0,
        "y": 0
      }
    ]
  }
}

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

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

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