How to save as PDF on Chrome using Selenium

in selenium
selenium Tutorials
1 Answers to this question

You will need to disable the Chrome PDF plugin and download the print window with desired compatibilities.

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);

You can also add the options.AddArgument(“---printing”); to automatically click the print option.

If you want to unleash your potential in this competitive field, please visit the Selenium Certification Training page for more information, where you can find the    Selenium Tutorial    and    Selenium Interview Questions FAQ's and answers    as well.

For more updates on the latest courses stay tuned to HKR Trainings.

To Top