skip to Main Content

I m trying to download a file in cypress but I m getting ENOTFOUND error. I have added necessary commands in config and command.js.

Code:

cy.downloadFile('https://en.wikipedia.org/wiki/File:Texas_Super_Kings_lgoo.png','cypress/downloads','example.png')

Plugin Details :
https://www.npmjs.com/package/cypress-downloadfile

Command in Config.js:

const { defineConfig } = require('cypress');
const { downloadFile } = require('cypress-downloadfile/lib/addPlugin')
module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      on('task', { downloadFile })
    },
  },
}),

Command in Commands.js:

require('cypress-downloadfile/lib/downloadFileCommand')

Error Description:

request to https://en.wikipedia.org/wiki/File:Texas_Super_Kings_lgoo.png failed, reason: getaddrinfo ENOTFOUND en.wikipedia.org

Tried all possible ways but not able to download any file. This is working fine when proxy is not set.

2

Answers


  1. Since you mentioned that this works when the proxy is not set, then there are other things to consider.

    In node.js, we had a similar problem with a different version of axios where downgrading it fixed the proxy problem. It can also be something to do with the method you’re using in cypress. Have you considered using cy.request() to see if you get the same behaviour? It may help to select different packages by providing proxy arguments.

    If the same behaviour is persistent across all the methods, check your proxy settings and see that it doesn’t block requests to https://en.wikipedia.org. This problem should likely be fixed through the proxy settings.

    There is a fine cypress documentation that describes different ways to overcome proxy problems for cypress.

    Check Firewall Settings that checks that it doesn’t interfere with the outbound rules.

    Try to troubleshoot the network issues, especially if the server is using VPN.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search