webdriverio-automation
Version:
WebdriverIO-Automation android ios project
28 lines (23 loc) • 755 B
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = closeWindow;
var _uuid = require("uuid");
async function closeWindow() {
delete this.currentFrame;
const page = this.getPageHandle();
await page.close();
this.windows.delete(this.currentWindowHandle);
const handles = this.windows.keys();
this.currentWindowHandle = handles.next().value;
if (!this.currentWindowHandle) {
const page = await this.browser.newPage();
const newWindowHandle = (0, _uuid.v4)();
this.windows.set(newWindowHandle, page);
this.currentWindowHandle = newWindowHandle;
}
const newPage = this.windows.get(this.currentWindowHandle);
await newPage.bringToFront();
return this.currentWindowHandle;
}