Save as PDF chrome using selenium
I'm looking to automate "Save as PDF" in Chrome using selenium. AFAIK not supported by selenium out of the box. So I am trying to write my own. I have a problem. In fact, clicking on the "Print" button on my web page opens a new window with the option to print. I am trying to switch to this window using SwitchTo. But this time is always.
+3
source to share
2 answers
You can try to disable the Chrome pdf plugin and load the promt window with the required capabilities. Something like that:
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability("download.default_directory","C:");
cap.setCapability("download.prompt_for_download","false");
cap.setCapability("directory_upgrade","true");
cap.setCapability("plugins.plugins_disabled","Chrome PDF Viewer");
WebDriver driver = new ChromeDriver(cap);
+1
source to share