GoogleChromeLabs / chrome-for-testing

https://googlechromelabs.github.io/chrome-for-testing/
Apache License 2.0
704 stars 83 forks source link

Downloads of any file with selenium and Chrome for testing is not working #139

Closed pranesh517 closed 4 days ago

pranesh517 commented 3 months ago

I am trying to automate a scenario where PDF file will be opened when clicked on a link. I am trying to download this PDF and do some validations. With below code i am not able to download the PDF at said location. Code snippet:

System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/src/main/resources/browserDriver/chromedriver.exe"); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setBinary( System.getProperty("user.dir") + "/src/main/resources/browserDriver/chrome-win64/chrome.exe"); chromeOptions.addArguments("--allow-running-insecure-content"); chromeOptions.addArguments("--incognito"); chromeOptions.setAcceptInsecureCerts(true); chromeOptions.addArguments("disable-popup-blocking"); HashMap<String, Object> chromePrefs = new HashMap<>(); chromePrefs.put("plugins.always_open_pdf_externally", true); chromePrefs.put("download.default_directory", System.getProperty("user.dir")+"/src/main/resources/downloads"); chromePrefs.put("download.prompt_for_download", false); chromePrefs.put("download.directory_upgrade", true); chromePrefs.put("safebrowsing.enabled", true); chromeOptions.setExperimentalOption("prefs", chromePrefs); driver = new ChromeDriver(chromeOptions);

In above code snippet i am setting path to download the file.

Selenium version: 4.22.0 Chrome for testing - 126.0.6478.126 OS - Windows 11

mathiasbynens commented 4 days ago

[!IMPORTANT] This issue tracker tracks bugs with the Chrome for Testing availability dashboard and its API.