Prompt_for_download is still appearing after setti

2019-02-18 07:06发布

问题:

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',
            },

        },

    },
},

回答1:

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:

  • Setting chromedriver preferences on protractor tests