Closing a window.confirm in protractor with phantomJs

偶尔善良 提交于 2019-12-08 05:40:31

Since there is no support yet for switchTo().alert() for PhantomJS/GhostDriver

I went for the following solution : mocking window.confirm as following :

beforeEach(function() {
    // bypassing PhantomJS 1.9.7/GhostDriver window.confirm (or alert) bug.
    // as WebDriver's switchTo().alert() is not implemented yet.
    browser.executeScript('window.confirm = function() {return true;}')
});

NB: I used jasmine for my Protractor tests, therefore I needed to put it in the beforeEach, else it would have no effect.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!