I am automating a web application using TestCafe with JavaScript. In the middle of the flow, I get a print window(Ctrl+P) where we get the preview and save and cancel buttons. I need to click on the cancel button. But my TestCafe controller is not switching to the print window. It is still on the web application page only.
TestCafe does not allow you to automate the Print dialog because TestCafe does not have access to buttons of the Print dialog.
The Print dialog is part of the browser functionality, not the webpage functionality, so we assume that the Print Dialog should be treated as alert, confirm dialogs, and others (https://testcafe.io/documentation/402684/reference/test-api/testcontroller/setnativedialoghandler).
We have an issue to support the Print Dialog in a way similar to the alert dialog: https://github.com/DevExpress/testcafe/issues/2331