【发布时间】:2015-05-20 11:28:21
【问题描述】:
如何在 Jasmine JS 中关闭原生网页浏览器弹出窗口?
我无法成功关闭此对话框,并且它一直显示在所有运行中。
请您帮忙!
代码:
describe('LiveSite Portal - Client perform a call', function() {
it('LiveSite - Home Page', function() {
liveSiteHome();
});
it('LiveSite Portal - Client perform a call', function() {
browser.getAllWindowHandles().then(function (handles) {
browser.switchTo().window(handles[handles.length - 1]);
var alertDialog = browser.switchTo().alert().thenCatch(function (e) {
if (e.code !== 27) { throw e; }
})
.then(function (alert) {
if (alert) {
expect(alertDialog.getText()).toEqual("External Protocol Request");
return alert.dismiss()
}
element(by.css("span.hide-sm.ng-binding")).click();
browser.sleep(3000);
});
//close the native popup
browser.switchTo().window(handles[0]);
browser.sleep(5000);
});
});
});
实际结果:
【问题讨论】:
-
你的最终目标是什么?你想启动一个应用程序还是什么都不做?另外,您是否与 Google Chrome 相关联,或者是否可以使用 Firefox 特定的解决方案?
-
我想“什么都不做”,但我还需要通过 chrome 和 firefox 运行它.. @alecxe
标签: node.js google-chrome selenium jasmine protractor