TheBrainFamily / chimpy

Develop acceptance tests & end-to-end tests with realtime feedback.
https://thebrainfamily.github.io/chimpy
MIT License
52 stars 28 forks source link

How to get Chrome headless to download files? #108

Open samhatoum opened 6 years ago

samhatoum commented 6 years ago

Issue by rsshilli Wednesday Feb 07, 2018 at 06:16 GMT Originally opened as https://github.com/xolvio/chimp/issues/679


How do I download files using Chrome headless? I see that:

I'm having a hard time piecing together how I get this working from my Chimp world.

Versions:

I've tried a number of things playing with the configuration, trying things like this below, but nothing works:

chimpOptions.webdriverio.desiredCapabilities = {
  chromeOptions: {
    args : ["--no-sandbox", "--headless", "--disable-gpu", "--window-size=1050,900"],
    prefs: {
      "credentials_enable_service": false,
      "Browser.setDownloadBehavior": {behavior : "allow", downloadPath: path.join((process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE), "Downloads")},
      "profile": {
        "password_manager_enabled": false,
        "default_content_setting_values": { "automatic_downloads": 1 }
      }
    }
  },
};

My mechanism for downloading a file is to click on the download link and then use fs to wait for the file on the file system, which never shows up :(. This worked fine before adding --headless