How to set preference for downloading .dmg file using WebdriverIO?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 05:10:01

问题


I want to download a .dmg file using webdriverIO and when the link has been clicked the file download popup pops out which is a .dmg file. How can I handle the popup which asks "save" or "cancel"?


回答1:


If the problem is save popup then you can avoid the popup by setting the default download location for the browser.

For CHROME: In the wdio.conf.js file, in the capabilities add the below: Before adding make sure you have defined downloadDir with the default path where the file needs to be saved.

capabilities: [{
    browserName: 'chrome',
    // this overrides the default chrome download directory with our temporary one
    chromeOptions: {
      prefs: {
        'download.default_directory': downloadDir
      }
    }
  }]

This code will set the default download directory and you will not see the pop up anymore.

more information: https://blog.kevinlamping.com/downloading-files-using-webdriverio/

Thanks, Naveen



来源:https://stackoverflow.com/questions/56001733/how-to-set-preference-for-downloading-dmg-file-using-webdriverio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!