• <small id='RI4WZ'></small><noframes id='RI4WZ'>

  • <tfoot id='RI4WZ'></tfoot>
  • <legend id='RI4WZ'><style id='RI4WZ'><dir id='RI4WZ'><q id='RI4WZ'></q></dir></style></legend>

    <i id='RI4WZ'><tr id='RI4WZ'><dt id='RI4WZ'><q id='RI4WZ'><span id='RI4WZ'><b id='RI4WZ'><form id='RI4WZ'><ins id='RI4WZ'></ins><ul id='RI4WZ'></ul><sub id='RI4WZ'></sub></form><legend id='RI4WZ'></legend><bdo id='RI4WZ'><pre id='RI4WZ'><center id='RI4WZ'></center></pre></bdo></b><th id='RI4WZ'></th></span></q></dt></tr></i><div id='RI4WZ'><tfoot id='RI4WZ'></tfoot><dl id='RI4WZ'><fieldset id='RI4WZ'></fieldset></dl></div>

          <bdo id='RI4WZ'></bdo><ul id='RI4WZ'></ul>

        使用量角器在 Firefox 上下载文件

        Download file on Firefox with protractor(使用量角器在 Firefox 上下载文件)
          <bdo id='0tmQ3'></bdo><ul id='0tmQ3'></ul>
        • <legend id='0tmQ3'><style id='0tmQ3'><dir id='0tmQ3'><q id='0tmQ3'></q></dir></style></legend>
        • <small id='0tmQ3'></small><noframes id='0tmQ3'>

              <tfoot id='0tmQ3'></tfoot>

                  <tbody id='0tmQ3'></tbody>
                • <i id='0tmQ3'><tr id='0tmQ3'><dt id='0tmQ3'><q id='0tmQ3'><span id='0tmQ3'><b id='0tmQ3'><form id='0tmQ3'><ins id='0tmQ3'></ins><ul id='0tmQ3'></ul><sub id='0tmQ3'></sub></form><legend id='0tmQ3'></legend><bdo id='0tmQ3'><pre id='0tmQ3'><center id='0tmQ3'></center></pre></bdo></b><th id='0tmQ3'></th></span></q></dt></tr></i><div id='0tmQ3'><tfoot id='0tmQ3'></tfoot><dl id='0tmQ3'><fieldset id='0tmQ3'></fieldset></dl></div>
                  本文介绍了使用量角器在 Firefox 上下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要使用量角器在 Firefox 上下载一个 zip 文件.单击下载链接时,会弹出要求打开/保存文件的 Windows 对话框.那么我该如何处理.我需要将哪些参数传递给驱动程序?使用 chrome 我可以做到这一点下载: {'prompt_for_download':假},

                  I need to download a zip file on Firefox with protractor. On clicking on download link, Windows dialog asking to Open/Save the file pops up. So How can I handle that. What args do I need to pass to driver? With chrome I can do that with download: { 'prompt_for_download': false },

                  但是我应该用 Firefox 做什么.

                  but what should i do with firefox.

                  推荐答案

                  问题是 - 您无法通过量角器/硒操作另存为..."对话框.您应该首先避免打开它,让 firefox 自动下载指定 mime 类型的文件 - 在您的情况下为 application/zip.

                  The problem is - you cannot manipulate that "Save As..." dialog via protractor/selenium. You should avoid it being opened in the first place and let firefox automatically download the files of a specified mime-type(s) - in your case application/zip.

                  换句话说,您需要使用自定义 Firefox 来启动 Firefox配置文件设置适当的偏好:

                  In other words, you need to fire up Firefox with a custom Firefox Profile setting the appropriate preferences:

                  var q = require("q");
                  var FirefoxProfile = require("firefox-profile");
                  
                  var makeFirefoxProfile = function(preferenceMap, specs) {
                      var deferred = q.defer();
                      var firefoxProfile = new FirefoxProfile();
                  
                      for (var key in preferenceMap) {
                          firefoxProfile.setPreference(key, preferenceMap[key]);
                      }
                  
                      firefoxProfile.encoded(function (encodedProfile) {
                          var capabilities = {
                              browserName: "firefox",
                              firefox_profile: encodedProfile,
                              specs: specs
                          };
                  
                          deferred.resolve(capabilities);
                      });
                      return deferred.promise;
                  };
                  
                  exports.config = {
                      getMultiCapabilities: function() {
                          return q.all([
                              makeFirefoxProfile(
                                  {
                                      "browser.download.folderList": 2,
                                      "browser.download.dir": "/path/to/save/downloads",
                                      "browser.helperApps.neverAsk.saveToDisk": "application/zip"
                                  },
                                  ["specs/*.spec.js"]
                              )
                          ]);
                      },
                  
                      // ...
                  }
                  

                  这里我们基本上是在说:Firefox,请自动下载 zip 文件,而不是询问 /path/to/save/downloads 目录.

                  Here we are basically saying: Firefox, please download zip files automatically, without asking into the /path/to/save/downloads directory.

                  这篇关于使用量角器在 Firefox 上下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What are valid deviceNames for Chrome emulation testing with Protractor?(使用 Protractor 进行 Chrome 模拟测试的有效设备名称是什么?)
                  Protractor Check if Element Does Not Exist(量角器检查元素是否不存在)
                  Protractor e2e Tests Login Redirection(Protractor e2e 测试登录重定向)
                  Explain about async/ await in Protractor(解释 Protractor 中的 async/await)
                  Protractor browser.wait doesn#39;t wait(量角器 browser.wait 不等待)
                  How to use Protractor with Angular 2?(如何在 Angular 2 中使用量角器?)
                    <bdo id='VbFSN'></bdo><ul id='VbFSN'></ul>

                    <legend id='VbFSN'><style id='VbFSN'><dir id='VbFSN'><q id='VbFSN'></q></dir></style></legend>

                      <tbody id='VbFSN'></tbody>
                        • <tfoot id='VbFSN'></tfoot>

                          <small id='VbFSN'></small><noframes id='VbFSN'>

                            <i id='VbFSN'><tr id='VbFSN'><dt id='VbFSN'><q id='VbFSN'><span id='VbFSN'><b id='VbFSN'><form id='VbFSN'><ins id='VbFSN'></ins><ul id='VbFSN'></ul><sub id='VbFSN'></sub></form><legend id='VbFSN'></legend><bdo id='VbFSN'><pre id='VbFSN'><center id='VbFSN'></center></pre></bdo></b><th id='VbFSN'></th></span></q></dt></tr></i><div id='VbFSN'><tfoot id='VbFSN'></tfoot><dl id='VbFSN'><fieldset id='VbFSN'></fieldset></dl></div>