Is it possible to disable file download in chrome using selenium
By Setting this policy the users can’t bypass the download security and to achieve the same using Selenium, we can set the “download_restrictions” preference as mentioned below:
How to do it in your Automation Using Selenium:
ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<>();
WebDriver driver = new ChromeDriver(options);
Please find the below code and their meaning for download Restrictions within Chrome:
- 0 = No special restrictions.
- 1 = Block malicious downloads and dangerous file types.
- 2 = Block malicious downloads, uncommon or unwanted downloads and dangerous file types.
- 3 = Block all downloads.
- 4 = Block malicious downloads.
- Version ≥ 61.