The Get Window Handles command of the WebDriver API returns a list of all WebWindow
s. Each tab or window, depending on whether you are using a tabbed browser, is associated by a window handle that is used as a reference when switching to the window.
In order to determine whether or not a particular interaction with the browser opens a new window, one can obtain the set of window handles before the interaction is performed and compare it with the set after the action is performed.
Syntax
Method | URI template |
---|---|
GET |
/session/{session id}/window/handles |
URL parameters
session id
- Identifier of the session.
Errors
- Invalid session ID
- Session does not exist.
Specifications
Specification | Status | Comment |
---|---|---|
WebDriver The definition of 'Get Window Handles' in that specification. |
Candidate Recommendation | Initial definition |
Browser compatibility
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | No1 | No2 | 55 | 7 | No1 | No3 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | Opera Android | iOS Safari | Samsung Internet |
---|---|---|---|---|---|---|---|
Basic support | No1 | No1 | No2 | No | No1 | No3 | No4 |
1. To enable Chromium support, include {"goog:chromeOptions": {"w3c": true}}
in the capabiliites when running the command.
2. The vendor-supported implementation for Edge is non-spec-conforming and incompatible.
3. The vendor-supported implementation for Safari is non spec-conforming and incompatible.
4. The vendor-supported implementation for Samsung Internet is non-spec-conforming and incompatible.
See also
- Switch To Window command
- Get Window Handle command
- Close Window command