.window.getHandle() Suggest edits
Retrieve the current window handle.
WebDriver does not make the distinction between windows and tabs. So, if your site opens a new tab or window, you can work with it using a window handle.
Usage
.window.getHandle([callback])
Example
module.exports = {
'get current window handle': function (browser) {
browser.window.getHandle(function (result) {
console.log('current window handle is:', result.value);
});
},
'get current window handle with ES6 async/await': async function (browser) {
const windowHandle = await browser.window.getHandle();
console.log('current window handle is:', windowHandle);
}
}
Parameters
Name | Type | description |
---|---|---|
callback |
function | Callback function which is called with the result value. |
Returns
Type | description |
---|---|
string | A unique identifier representing the window handle for the current window. |