Is there a way to prevent the print window from automatically popping up when a page loads using Selenium?
So far, I have tried using the Robot class to press the escape key, but it only works 80% of the time. I have also experimented with Firefox preferences and overriding the window.print
function.
Unfortunately, none of these methods completely disable the print window on page load. I am seeking guidance on how to achieve this specifically for Firefox and Selenium (Google Chrome solutions are optional).
I am unable to access the JavaScript code of the target website, as it is obfuscated, making it difficult to pinpoint which script triggers the print window on page load.
Upon further investigation, I discovered that the print window appears due to a specific piece of JavaScript code:
n.iframeNode.on('load', function () {
n.iframeNode[0].elem.contentWindow.print()
}),
I have also attempted different approaches such as disabling JavaScript entirely, tinkering with JS events, and exploring proxy concepts without success.
If you have any insights or suggestions on how to effectively stop the print window from appearing on page load, please share them. Your assistance in resolving this issue would be greatly appreciated.