question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chrome sendChromiumCommand 'Page.setDownloadBehavior' failing - UnsupportedOperationError

See original GitHub issue

Bug report

  • Node Version: 10.16.0
  • Protractor Version: 5.4.2
  • Angular Version: 8
  • Browser(s): Chrome (headless / normal)
  • Operating System and Version Windows 10
  • Your protractor configuration file
capabilities: {
    browserName: 'chrome',

    chromeOptions: {
      args: useHeadlessBrowser ? ["--headless", "--window-size=1920,1080"] : undefined,
      useAutomationExtension: false,

      // Set download path and avoid prompting for download even though
      // this is already the default on Chrome but for completeness
      // https://chromium.googlesource.com/chromium/src/+/master/chrome/common/pref_names.cc
      prefs: {
        "download": {
          "prompt_for_download": false,
          "directory_upgrade": true,
          "default_directory": downloadDirectory,
          "download_directory": downloadDirectory,
          "download_dir": downloadDirectory,
          "download_restrictions": 0,
        }
      }
    }
  },

Before any tests run I send the below command to Chrome to enable file downloads in headless Chrome

    // returns full path
    const downloadDirectory = Utils.getTempDirectoryPath();

    Utils.log(`Setting Chrome download behaviour to directory ${downloadDirectory}`);
    browser.driver.sendChromiumCommand('Page.setDownloadBehavior', {
      behavior: 'allow',
      downloadPath: downloadDirectory
    });

This has stopped working on Chrome 74+ with the error.

UnsupportedOperationError: POST /session/ac771ec3019f7b4c7191e2c9ae2b2056/chromium/send_command

We are unable to run test on Chrome 74 now and cannot get any of our file download tests to work as headless Chrome is unable to download a file with issuing the above command.

Is there any other suggested way to enable file downloads in headless Chrome without issuing the above command?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:13

github_iconTop GitHub Comments

1reaction
BZalduacommented, Sep 18, 2019

I made it work using this versions:

  • Protractor: 5.4.2
  • Selenium standalone server: 3.141.59
  • Chrome: 77.0.3865.40

I launched Chome in headlles way and everything is fine. Actually, it seems like browser.driver.sendChromiumCommand(...) configuration is not longer necessary. I deleted it and everything works fine for me.

I did not try setting "w3c":false but with the versions I mention and deleting the configuration, everything seems to work.

0reactions
vmgustavocommented, Oct 20, 2021

Using chromedriver from this link and a chromium binary from this link I was able to use the driver.execute_cdp_cmd method.

params = {'behavior': 'allow', 'downloadPath': path}
driver.execute_cdp_cmd('Page.setDownloadBehavior', params)
Read more comments on GitHub >

github_iconTop Results From Across the Web

2454 - Headless mode doesn't save file downloads - Monorail
If one uses headless Chrome, the problem is that no file is downloaded. ... From: Task: Custom Command: sendChromiumCommand("Page.setDownloadBehavior" ...
Read more >
Chromium/Chrome headless - file download not working?
Nice - this worked for me. A lot of the other answers only talk about sending the Page.setDownloadBehavior command, and not setting the...
Read more >
Downloading the files in headless chrome - Katalon Community
Hi I want to download the file in headless chrome. ... setDownloadBehavior"); Map<String, String> params = new HashMap<>(); ...
Read more >
protractor Chrome sendChromiumCommand 'Page ... - Git Memory
Chrome sendChromiumCommand 'Page.setDownloadBehavior' failing - UnsupportedOperationError. Open jonsamwell opened this issue 3 years ago • 13 comments ...
Read more >
Fix file download errors - Google Chrome Help
Contact the website owner. To help find your downloaded file, learn how to view a downloaded file. Get help with a specific error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found