Protractor - Jasmine - Download file to a relative path

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 04:57:36

As explained in the questions you have quoted, You can control where the file downloads using the below option

'chromeOptions': {
       prefs: {
        download: {
          'prompt_for_download': false,
          'default_directory': <<absolutePath>>
        }
      }
    }

Coming to your question on how to accomplish this when running on different machines, the answer is - Generate absolute Path from relative path and pass it onto Chrome Options.

var path = require('path');
var downloadsPath = path.resolve(__dirname, './downloads');
................
'chromeOptions': {
           prefs: {
            download: {
              'prompt_for_download': false,
              'default_directory': downloadsPath
            }
          }
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!