Reputation: 877
I am looking to automate "Save as PDF" of Chrome using selenium. AFAIK it is not supported by the Selenium out of the box. Therefore, i am trying to write my own. I am having an issue. Actually clicking on the Print button in my webpage opens a new window with printable area. I am trying to switch to this window using SwitchTo. But it is timing out always.
Upvotes: 6
Views: 9094
Reputation: 210
You could try to disable the Chrome PDF plugin and download promt window with desired capabilities. Something like this:
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);
Upvotes: 1
Reputation: 93
You can add the options.AddArgument("--kiosk-printing"); to have it automatically click the print button.
That is working for me but I have a problem setting the printer to Save as PDF. It is printing to the printer instead.
Upvotes: 2