I have a requirement to download a PDF file using Selenium Webdriver (#Java). Steps:
- Save Product
- Click on Print
- New window with url opens
- Save PDF.
Can anybody please help me in automating the above steps.
I have a requirement to download a PDF file using Selenium Webdriver (#Java). Steps:
Can anybody please help me in automating the above steps.
For downloads, I put the follwing code before instantiating the Chrome browser
HashMap<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", "YouSaveDirectoryHere");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(ChromeOptions.CAPABILITY, options);
options.merge(cap);
This automatically downloads the file without a popup when clicking on the download button.
Hope it helps!