windowHandles

Retrieve the list of all window handles available to the session.

Usage

1
browser.windowHandles();

Example

windowHandles.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
it('should return all window handles', function () {
browser.url('http://localhost/one.html');
browser.newWindow('http://localhost/two.html');

var windowHandles = browser.windowHandles()
console.log(windowHandles);
// Outputs something like
// {
// state: 'success',
// sessionId: '31dc8253-a27e-4bae-8d20-338d6b0541c9',
// hCode: 273402755,
// value:
// [ 'CDwindow-CBFE1412-8D46-495C-96B4-42E04F9153C0',
// 'CDwindow-BD7BE568-52F2-4552-B834-FE2D041DCE5B' ],
// class: 'org.openqa.selenium.remote.Response',
// status: 0
// }
});

Returns

  • <String[]>: a list of window handles