AquariusPotter
AquariusPotter

Reputation: 156

Test Export / Download file with protractor

i got a problem. Can someome help me ! i want to export file from export button in js page and download file to a directory in my project for testing. But i cant change download default_directory. when i run test, it was downloaded in /Downloads , not /resource/download/ directory. How can i set download directory for protractor This is my protractor-config.js

directConnect: true,
multiCapabilities: [
    {
        browserName: 'firefox',
        acceptInsecureCerts: true,
        'moz:firefoxOptions': {
            args: ["--headless"]
        },
        prefs: {
            'download': {

                'prompt_for_download': false,
                'default_directory': process.cwd() + "/resources/test/download",
                'directory_upgrade': true
            },
        },
    },
    {
        browserName: 'chrome',
        acceptInsecureCerts: true,
        chromeOptions: {
            args: [
                "--headless",
            ]
        },
        prefs: {
            'download': {
                'prompt_for_download': false,
                'default_directory': process.cwd() + "/resources/test/download",
                'directory_upgrade': true,
            },
        },
    }
],

Upvotes: 0

Views: 408

Answers (1)

Madhan Raj
Madhan Raj

Reputation: 1442

Try the below one,

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

            prefs: {
                download: {
                    'prompt_for_download': false,
                    'directory_upgrade': true,
                    'default_directory': process.cwd() + '/resources/test/download' // change in this place
                }
            }
        }
    },

Hope it helps you

Upvotes: 1

Related Questions