[英]How to handle download file save dialog in firefox through protractor
I'm having a problem running a protractor test.我在运行量角器测试时遇到问题。 Test has to download a file which is facing a popup in firefox as shown below:
测试必须下载一个在 Firefox 中面临弹出窗口的文件,如下所示:
Can someone please help me how to avoid this on firefox?有人可以帮助我如何在 Firefox 上避免这种情况吗?
I'm using protractor: 5.4.1, NodeJS: 8.11.2我正在使用量角器:5.4.1,NodeJS:8.11.2
My conf.js Capabilities: capabilities: { 'browserName': 'firefox', 'marionette' : true, 'shardTestFiles': true, 'maxInstances': 1, "browser.helperApps.neverAsk.saveToDisk": "application/zip" },我的 conf.js 功能:功能:{ 'browserName': 'firefox', 'marionette' : true, 'shardTestFiles': true, 'maxInstances': 1, "browser.helperApps.neverAsk.saveToDisk": "application/zip" },
Note: Chrome doesn't have this so it's working fine there.注意:Chrome 没有这个,所以它在那里工作正常。
Regards, Naresh Surya问候, Naresh Surya
you can try this:你可以试试这个:
export let config: Config = {
seleniumAddress: '...',
capabilities: {
'browserName': 'firefox',
'moz:firefoxOptions': {
prefs: {
'browser.download.folderList' : 2,
'browser.download.dir' : downloadsPath,
'services.sync.prefs.sync.browser.download.useDownloadDir' : true,
'browser.download.useDownloadDir' : true,
'browser.download.manager.closeWhenDone':true,
'browser.download.manager.showWhenStarting': false,
'browser.helperApps.alwaysAsk.force':false,
'browser.download.manager.showAlertOnComplete':false,
'browser.download.manager.useWindow':false,
'browser.helperApps.neverAsk.saveToDisk': 'application/pdf,application/csv,text/plain,application/vnd.csv',
'pdfjs.disabled': true
},
}
...
Being dowloadsPath your variable with the path where you want it to save.将 dowloadsPath 您的变量与您希望它保存的路径一起使用。
If it does not work for you, you can always try with many other types like:如果它不适合您,您可以随时尝试使用许多其他类型,例如:
application/xml,text/plain,text/comma-separated-values,application/excel,application/octet-stream,application/xlsx,application/xls,aplication/vnd.ms-excel,application/vnd.ms-excel.addin.macroenabled.12,application/vnd.ms-excel.sheet.binary.macroenabled.12,application/vnd.ms-excel.template.macroenabled.12,application/vnd.ms-excel.sheet.macroenabled.12,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/xml,application/csv,application/pdf,application/octet-stream,application/x-winzip,,application/x-gzip
If you have a way to prevent firefox opening the file .xml or csv, just let me know.如果您有办法阻止 Firefox 打开 .xml 或 csv 文件,请告诉我。 So far, mine is only working for pdf.
到目前为止,我的仅适用于 pdf。
Here you have more info:http://kb.mozillazine.org/Firefox_: FAQs :_About:config_Entries在这里您有更多信息:http://kb.mozillazine.org/Firefox_:常见问题解答:_About:config_Entries
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.