我正在开发一个Angular应用程序,我有一个Protractor的问题。 问题是应用程序在卸载时必须有此消息:
在量角器测试中,我收到此错误:
- Failed: unexpected alert open: {Alert text : Do you want to leave this site}
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)
浏览,我找到了这个解决方案:
var alertDialog = browser.switchTo().alert();
alertDialog.accept();
但在这种情况下,我得到了这个:
- Failed: unexpected alert open: {Alert text : Do you want to leave this site}
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)
- Failed: Error while waiting for Protractor to sync with the page: "window.getAllAngularTestabilities is not a function"
答案 0 :(得分:1)
这是一种解决方法:
browser.executeScript('window.onbeforeunload = ()=>{}');
您可以在此处找到更多信息:https://github.com/angular/protractor/issues/308