Chromedriver version 121 onwards forces a "Save as" window when downloading files in incognito mode

593 Views Asked by At

I'm using Webdriverio to test a web app with logins and incognito mode is required for parallel running of a test suite.

However chromeDirver 121+ while running in incognito mode, downloading a file prompts the "save as" dialog to appear over the browser session and the file is not downloaded.

Is there an preference or arg for chrome that I'm missing for this version bump?

ChromeOptions I'm using are as follows (wdio conf format):

            'goog:chromeOptions': {
                prefs: {
                    download: {
                        default_directory: downloadDir,
                        prompt_for_download: false,
                        extensions_to_open: 'applications/pdf',
                        directory_upgrade: true
                    },
                    savefile: {
                        default_directory: downloadDir
                    },
                    profile: {
                        default_content_setting_values: {
                            automatic_downloads: 1,
                        },
                        default_content_settings: {
                            popups: 0,
                        },
                    },
                    plugins: {
                        plugins_disabled: 'Chrome PDF Viewer',
                        always_open_pdf_externally: true,
                    },
                },
                args: [
                    '--window-size=1800,1500',
                    '--incognito',
                    '--print-to-pdf',
                    '--allow-running-insecure-content',
                    '--ignore-certificate-errors',
                    '--disable-features=DownloadBubble,DownloadBubbleV2',
                    '--no-sandbox',
                ],
                localState: {
                    browser: {
                        enabled_labs_experiments: ["download-bubble-v2@2", "download-bubble@2"],
                    },
                },
            }

This configuration will work in 120, upgrading to 121 is the breaking point. When I ran into issues in version 121 I Added the following block to chromeOptions

                    savefile: {
                        default_directory: downloadDir
                    },

Expecting this to be passed to the file explorer, however it hasn't made any difference.

P.S. This behaviour has cropped up in previous versions, I added the "localState" block when upgrading to 117 and then the "--disable-features" arg when upgrading to 119, both to fix exactly the same "Save as" issue.

1

There are 1 best solutions below

0
Anil Ca On

Even I faced the same issue but it can be easily solved by using the following :

browser.cdp('page', setDownloadBehavior', {
behavior: 'allow',
downloadPath: //your path });