This seems to be a pretty simple question, but I really can't find an answer online and I was not able to find an answer myself.
How can I simulate the selected option in my tests (with Protractor)? Is it possible to access the confirmation box and "click" either Ok or Cancel and act accordingly in my test? I'm guessing something like
I guess I can answer my own question as this may be of use to someone else.
First, you need to get your Protractor instance:
var ptor = protractor.getInstance();
Confirmation dialogs are handled the same way as alerts, so something like this did the trick:
var alertDialog = ptor.switchTo().alert(); alertDialog.accept(); // Use to accept (simulate clicking ok) alertDialog.dismiss(); // Use to simulate cancel button
So simple and elegant, yet hard to find an answer. Hope this helps someone else