用量角器在Firefox上下载PDF文件不起作用

时间:2019-03-30 14:52:01

标签: angular firefox protractor e2e-testing

我的angular 5 e2e测试中存在问题,我需要使用firefox自动下载pdf。它不应在Firefox中显示“另存为..”窗口。

我已经在这里尝试过stackoverflow的一些解决方案,但是它们似乎对我不起作用。

这是我的protractor.conf.js文件的内容:

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName' : 'firefox',
    'moz:firefoxOptions': {
      prefs: {
        'browser.download.folderList': 2,
        'browser.download.dir' : process.cwd() + "/resources/test/download",
        'services.sync.prefs.sync.browser.download.useDownloadDir': true,
        'browser.download.useDownloadDir': true,
        'browser.download.manager.alertOnEXEOpen': false,
        'browser.download.manager.closeWhenDone': true,
        'browser.download.manager.focusWhenStarting': false,
        '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',
      },
    },
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  onPrepare() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
    require("zone.js/dist/zone-node");
    require("zone.js/dist/long-stack-trace-zone");
    require("zone.js/dist/async-test");
    require("zone.js/dist/fake-async-test");
    require("zone.js/dist/sync-test");
    require("zone.js/dist/proxy");
    require("zone.js/dist/jasmine-patch");
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }
};

但是在量角器测试中,单击下载pdf按钮时,firefox仍会打开“另存为...”提示,并且不会自动下载pdf。 但是,它会在测试过程中创建“ / resources / test / download”文件夹。但是它是空的。

我正在Mac OS Mojave(10.14.4)和package.json中使用Firefox版本66.0.2:

"selenium-webdriver": "^4.0.0-alpha.1",
"jasmine-core": "2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "~1.4.1",
"karma-firefox-launcher": "^1.1.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "~0.2.2",
"protractor": "~5.4.0",

我想念什么吗?

0 个答案:

没有答案