webdriverio-automation
Version:
WebdriverIO-Automation android ios project
23 lines (20 loc) • 621 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getWindowHandles;
var _uuid = require("uuid");
async function getWindowHandles() {
let newPages = await this.browser.pages();
const stalePageIds = [];
this.windows.forEach((page, id) => {
if (newPages.includes(page)) {
newPages = newPages.filter(newPage => page !== newPage);
} else {
stalePageIds.push(id);
}
});
stalePageIds.forEach(pageId => this.windows.delete(pageId));
newPages.forEach(page => this.windows.set((0, _uuid.v4)(), page));
return Array.from(this.windows.keys());
}