问题
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