简体   繁体   English

如何通过量角器处理Firefox中的下载文件保存对话框

[英]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-separat‌​ed-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.

相关问题 如何使用量角器通过脚本处理windows文件上传和下载? - How to handle windows file upload and download through script using protractor? 使用量角器在Firefox上下载文件 - Download file on Firefox with protractor 如何从服务器下载文件并通过对话框保存 - How to download file from server and save it with dialog 在firefox中等待保存文件对话框 - Wait for save file dialog in firefox 如何使用mvc或javascript下载另存为对话框的文件 - How to download file with save as dialog using mvc or javascript 是否可以通过jquery在文件下载对话框中禁用或隐藏文件“保存”选项? - Is it possible to disable or hide file “save” option in file download dialog through jquery? Chrome,Firefox在其文件保存对话框中分别将“:”转换为“-”和“ _” - Chrome, Firefox converting “:” to “-” and “_” respectively in their file save dialog 下载属性不建议保存对话框中的文件扩展名 - download attribute not suggesting file extension in save dialog 另存为“文件下载”对话框在Chrome中不起作用 - save as File download dialog not working in chrome 强制浏览器在文件下载时打开“另存为”对话框 - Forcing browser to open “Save As” dialog on file download
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM