5

Problem

I'm testing downloading a file, but when I trigger the download, the "Save as..." prompt appears. I saw a solution in this SO question but it doesn't seem to work for me.

Config

My protractor config file looks like this (coffeescript):

exports.config =
  capabilities:
    browserName: "chrome"
    shardTestFiles: true
    maxInstances: 2
    chromeOptions:
      args: ['--no-sandbox', '--test-type=browser']
      prefs:
        download:
          prompt_for_download: false
          default_directory: '/'
          default_content_settings:
            popups: 0

More

On chromeOptions.pref webdriver docs states:

See the 'Preferences' file in Chrome's user data directory for examples.

I can't actually see default_directory in my own Chrome preferences file.

"download": {
  "directory_upgrade": true,
  "prompt_for_download": false
},

System

  • Protractor: Version 1.5.0 (pretty new)
  • Node: 0.10.28, 0.11.8 and 0.11.14
Community
  • 1
  • 1
Ashley Coolman
  • 11,095
  • 5
  • 59
  • 81

2 Answers2

7

Provide an absolute path to an existing directory in default_directory chrome preference.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • If I read this question/answer 6 hours ago it would have been a way much easier day for me :D – stsatlantis Sep 14 '16 at 16:01
  • Is there any way not to use the `absolutePath`? If I try to you the `relative` the `popups` option does not work! thanks for this solution – Bruno Soko Mar 01 '17 at 02:03
  • 3
    I had the same problem @BrunoSoko and I solved it using this `'default_directory': process.cwd() + '/your/relative/path/'` – davidrv87 May 22 '17 at 14:31
1

For me, the Save As prompt was appearing when I mentioned a slash at last in the path for example: A:\Proj\Downloads\ & didn't see any prompt when mentioned without a slash at the end of the path i.e A:\Proj\Downloads

Alisettar Huseynli
  • 944
  • 1
  • 11
  • 24
alvice8
  • 11
  • 1