2

I'm using Chrome as a browser and can't quite figure out how to dismiss a print dialog that appears on click of a particular button. I have tried using browser.dismissAlert(); and browser.keys([browser.Keys.ESCAPE]); to hit the escape button, and neither works. I'm not sure that Nightwatch is aware that there is a dialog at all.

I've been searching online and can't seem to find a solution... anyone got any ideas please?

Lauripops
  • 412
  • 1
  • 3
  • 11
  • Using Selenium you need to switch to the alert and accept it. [This answer](http://stackoverflow.com/a/13714614/1555990) although not specifically for your question, does have an example of how to switch to and accept an alert. – That1Guy Jun 07 '16 at 15:12
  • I did try that, and it hasn't worked, unfortunately! I've seen similar questions where people haven't had this issue in other browsers, so I have a feeling it's that Chrome isn't letting the test interact with it – Lauripops Jun 07 '16 at 15:25
  • If .acceptAlert() worked but .dismissAlert() , you can post this issue on github, may be it is a bug. – Bao Tran Jun 09 '16 at 07:32

1 Answers1

4

So, as it turns out, Selenium cannot handle Chrome dialogs. I did however find a solution by reading this page and adding --disable-print-preview to the chromeOptions in the nightwatch.json file in my project.

This dismissed the Chrome print dialog, but still brings up the Mac system dialog, and I don't think Selenium capabilities extends to system dialogs, so for the purpose of testing, I've just disabled the print functionality.

Shame I didn't find a better solution, but just wanted to update for those of you upvoting

Lauripops
  • 412
  • 1
  • 3
  • 11