3

I'm trying to download a file in my test. I've managed to start the download without getting the download prompt. the problem now is that I'm getting a warning saying that "This type of file can harm your computer.Do you want to keep...anyway?" and I need to choose 'Discard' or 'Keep'. I've tried to find chromeOptions for that - unsuccessfully. currently using those args:

args: ['--disable-popup-blocking="true", --allow-unchecked-dangerous-downloads="true", --disable-download-notification="true"']

any ideas?

user2880391
  • 2,241
  • 6
  • 26
  • 59
  • Did you got the answer for your question..? I tried with the safe browsing as per chrometoaster answer but it is not working. :( – mkHun Apr 07 '20 at 10:02

2 Answers2

2

Took me a day of googling and almost gave up... but i found a solution from How to disable 'This type of file can harm your computer' pop up

Will post the solution here since it was frikin hard to track it down when using protractor as the keyword

prefs = {
    'safebrowsing' => {
        'enabled' => true,
    }
}

oddly enough, you need to "turn on" safe browsing to make the message dissapear

Community
  • 1
  • 1
  • Where I need to add this piece of code.? I have added in the protractor.conf.js file under `exports.config = {` but it is not working, I have changed your code to `prefs: {'safebrowsing':{'enabled':true}}` like this, but it is not working. – mkHun Apr 07 '20 at 10:05
  • For anyone reading this now I managed to get this working `chromeOptions: { args: ['--safebrowsing-disable-download-protection'], prefs: { 'safebrowsing': true, downloads: { 'prompt_for_download': false } } },` – DublinDev Apr 14 '20 at 10:14
0

Try the following flags:

alecxe
  • 414,977
  • 106
  • 935
  • 1,083
  • Did you try using 1 or 0 instead of "true" "false"? – reutsey Apr 27 '16 at 13:45
  • @user2880391 please try the rfodge's suggestion. – alecxe Apr 27 '16 at 13:55
  • 1
    And if that doesn't work, you can also try using a chrome option pref instead of an arg. It would be like the solution shown here: http://stackoverflow.com/questions/33265701/protractor-allow-notifications-chrome-46 except you would probably want to try the pref of profile.managed_default_content_settings.popups with a value of 2 (1 is allow and 2 is block). – reutsey Apr 27 '16 at 14:23