Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
343 views
in Technique[技术] by (71.8m points)

javascript - Setting chromedriver preferences on protractor tests

Trying to find a solution to download files during my tests, i found this question that lead me to preferences file in chrome folder.

Apparently, there are no info about shutting the prompt for download or/and setting a default folder. Does anyone knows how i can do this?

Here's what i tried:

capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {

            prefs: {
                'downloads': {
                    'prompt_for_download': false,
                    'default_directory': '/downloads/'
                }
            }
        }
    },
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are doing it correctly, except you need to:

  • specify an absolute path to the "downloads" directory
  • add directory_upgrade option

Example:

capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {

            prefs: {
                download: {
                    'prompt_for_download': false,
                    'directory_upgrade': true,
                    'default_directory': '/absolute/path/here'
                }
            }
        }
    },

See also: Can't stop Protractor from displaying file download prompt


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...