How to handle this error in chrome browser using protractor.

Chrome driver through's following error: UnexpectedAlertOpenError: unexpected alert open: {Alert text : There are unsaved data, please save before you leave, otherwise your changes get lost!} I have used "browser.switchTo().alert().accept();" but this is not working, works fine in firefox. Please help me, help is greatly appreciated.
today, after struggling with this new problem for the past week or so, we found that the problem was fixed by using the latest Protractor version. Changing the package.json to "protractor": "*" did the job.
来源:https://stackoverflow.com/questions/38779693/unexpected-alert-open-error-browser-switchto-alert-accept-works-fine-i