Download in chrome

231 views
Skip to first unread message

Gary Passero

unread,
Feb 4, 2021, 4:15:36 PM2/4/21
to NightwatchJs
Hi,
I'm trying to test a scenario using NightwatchJS that involves downloading a file. When I click the component that starts the download, the browser is stuck awaiting for user approval to save it. I've tried every variation of config that I can find online to override the safety settings, like this (in my `nightwatch.conf.js` file)

```js
...
desiredCapabilities": {
  "browserName": "chrome",
  "javascriptEnabled": true,
  "chromeOptions": {
        "prefs": {
            "download": {
                "default_directory": `${__dirname}/downloads`,
                "prompt_for_download": false,
                "directory_upgrade": true,
            },
            "safebrowsing": {
                 "enabled": false,
             }
         }
...
```

I see that others here are successfully using Nightwatch to test download scenarios. Can someone give me the magic sauce to do so with Chrome driver?

Thank you

Gary



Juliet

unread,
Feb 10, 2021, 12:29:48 PM2/10/21
to NightwatchJs
HI,

I have used the following in the prefs config

          "prefs": {
            "download.default_directory": "YOUR DIR WHERE YOU WANT TO DOWNLAOD",
            "download.directory_upgrade": "true",
            "download.extensions_to_open": "",
            "download.prompt_for_download": "false",
            "profile.default_content_settings.popups": 0,
            "safebrowsing.enabled": "true"
          }



This works for me. 

Thanks,
J

Madhukumar NM

unread,
Jan 2, 2022, 12:00:16 AM1/2/22
to NightwatchJs
Hi Juliet,

downloaded file am not able to find in jenkins run, but in local am able to get the file. Is there any steps to get the file in jenkins where its running in aws instance ?

Thanks,
Madhukumar

Reply all
Reply to author
Forward
0 new messages