我想使用 webdriverIO 下载一个 .dmg 文件,单击链接后会弹出文件下载弹出窗口,这是一个 .dmg 文件。如何处理询问“保存”或“取消”的弹出窗口?
最佳答案
如果问题是保存弹出窗口,那么您可以通过为浏览器设置默认下载位置来避免弹出窗口。
对于 Chrome :
在 wdio.conf.js
文件中,在 capabilities
中添加以下内容:
Note: 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
goog:chromeOptions: {
prefs: {
'download.default_directory': downloadDir
}
}
}]
此代码将设置默认下载目录,您将不会再看到弹出窗口。
更多信息:https://blog.kevinlamping.com/downloading-files-using-webdriverio/
关于javascript - 如何使用 WebdriverIO 设置下载 .dmg 文件的首选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56001733/