@winning-test/component 0.0.44 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/edis5.6/page/Page.js +27 -0
- package/package.json +1 -1
package/edis5.6/page/Page.js
CHANGED
|
@@ -169,6 +169,33 @@ class Page extends require("@winning-test/autotest-webui").Page {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
/**
|
|
173
|
+
* 关闭打印窗口
|
|
174
|
+
* @param {Number} timeout 等待时间, 单位: ms
|
|
175
|
+
*/
|
|
176
|
+
async closePrintWindow(timeout = 10000) {
|
|
177
|
+
let count = timeout / 500;
|
|
178
|
+
while (count > 0) {
|
|
179
|
+
let windows = await this.browser.webDriver.getAllWindowHandles();
|
|
180
|
+
if (windows.length === 1) {
|
|
181
|
+
await this.browser.sleep(500);
|
|
182
|
+
count--;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
for (let i = windows.length; i > 0; i--) {
|
|
186
|
+
try {
|
|
187
|
+
await this.browser.switchToWindow(i);
|
|
188
|
+
await this.browser.webDriver.close();
|
|
189
|
+
break;
|
|
190
|
+
} catch (error) {
|
|
191
|
+
console.log(error);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
await this.browser.switchToWindow();
|
|
197
|
+
}
|
|
198
|
+
|
|
172
199
|
}
|
|
173
200
|
|
|
174
201
|
module.exports = Page;
|