6

I have this below config and already set prompt_for_download to false but for some reason, when I run the test, prompt for download dialogue is keep appearing. Am I doing something wrong?

For download code, I'm following solution from here and ChromeDriver 2.14.

Thanks.

capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
        args: ['--lang=en', '--start-maximized'],
        prefs: {
            'download': {
                'prompt_for_download': false,
                'default_directory': '/tmp/downloads',
            },

        },

    },
},
Community
  • 1
  • 1
user2388556
  • 287
  • 1
  • 7
  • 17

1 Answers1

14

I think you also need to add directory_upgrade:

prefs: {
    download: {
        prompt_for_download: false, 
        directory_upgrade: true,
        default_directory: '/tmp/downloads'
    },
},

Aside from that, make sure /tmp/downloads directory exists and there are permissions to write into it. Also see a similar issue:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • thanks for your @alecxe. I updated as per your solution and I'm still stuck at prompt to download dialogue. Full permission given to the directory. Anything else that I should check? Thanks. – user2388556 Mar 05 '15 at 21:32
  • @user2388556 two question: do you see the browser starting maximized (just checking whether the options are actually applied)? Also, is this a public site (so that I can also reproduce the problem)? – alecxe Mar 05 '15 at 22:25
  • @user2388556 also try changing the `default_directory` path to your home directory and see if it helps or not. – alecxe Mar 05 '15 at 22:26
  • browser is maximizing and it's downloading now. Just got the hint from your home directory then I realised that my directory is in D with my project file. So path that I set in my config doesn't exist in C drive where chrome is running and I went to create "/tmp/" on C. It's downloading now but it's still failing and says "data.json - Failed - Path too long" – user2388556 Mar 05 '15 at 22:42
  • 1
    @user2388556 good progress! I think the answer has actually helped to solve the problem described in the question. As for you last problem, try to set the path using backslashes. – alecxe Mar 05 '15 at 22:46
  • i tried this "\\tmp\\" and still having same issue. – user2388556 Mar 05 '15 at 23:15
  • @user2388556 should not it be `C:\\tmp\\downloads`? – alecxe Mar 05 '15 at 23:18
  • that trick works!!!! Thanks haha. Any reason why it won't work with /tmp/downloads? – user2388556 Mar 05 '15 at 23:57
  • @user2388556 well, it is windows and you have to provide a full path :) – alecxe Mar 05 '15 at 23:58
  • Ic. Thanks again mate :) . For my HTML reporter config, it works for `baseDirectory: '/tmp/screenshots',` on D drive lol. – user2388556 Mar 06 '15 at 00:01