Geek Culture
Published in

Geek Culture

Implementing Download Restrictions on Selenium Chromedriver

DownloadRestrictions

Allow download restrictions

Supported on:

  • Google Chrome (Linux, Mac, Windows) since version 61
  • Google Chrome OS (Google Chrome OS) since version 61

Description:

Setting the policy means users can’t bypass download security decisions.

Setting the policy to:

* Block dangerous downloads means all downloads are allowed, except for those that carry safety warnings.

* Block potentially dangerous downloads means all downloads allowed, except for those that carry safety warnings of potentially dangerous downloads.

* Block all downloads means all downloads are blocked.

* Block malicious downloads means all downloads are allowed, except for those assessed to be malware with high confidence. Unlike with dangerous downloads, this does not take into account file type, but does take into account the host.

* No special restrictions means the downloads go through the usual security restrictions based on safety analysis results.

  • 0 = No special restrictions
  • 1 = Block dangerous downloads
  • 2 = Block potentially dangerous downloads
  • 3 = Block all downloads
  • 4 = Block malicious downloads

How to implement it on Selenium:

Code:

 ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<>();
prefs.put("download_restrictions", 3);
options.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(options);

Note: These restrictions apply to downloads triggered from webpage content, as well as the Download link… menu option. They don’t apply to the download of the currently displayed page or to saving as PDF from the printing options. Read more about Safe Browsing ( https://developers.google.com/safe-browsing ).

Reference:

--

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

Phishing Is the Top Reason Behind Australian Data Breaches

How to create a Threat Landscape and rock your customer meetings

Ethereum-Push-Notification-Service (EPNS)

Flash Stock Firmware on Samsung GALAXY GRAND Prime SM-G530T

Flash Stock Rom on Samsung Galaxy

EndPoint Security has changed… Virus Protection is out.. But what is in?

{UPDATE} 1010 Mania Block King Puzzle Hack Free Resources Generator

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Dhoundiyal

Abhishek Dhoundiyal

Principal QA Manager at MakeMyTrip https://stackoverflow.com/users/5372079/abhishek-dhoundiyal

More from Medium

Protractor Tutorial: Handling iFrames & Frames in Selenium

Automate with Selenium (Part 2)

Automation Testing Tutorial Using Pycharm

How To Use Breakpoints For Debugging In Selenium WebDriver