【问题标题】:Protractor test fails in Firefox with "HTTP method not allowed"量角器测试在 Firefox 中失败,“HTTP 方法不允许”
【发布时间】:2020-05-14 17:07:04
【问题描述】:

如何修复“不允许使用 HTTP 方法”? 我正在使用 Angular 8,Firefox 是 Ubuntu 19.04 上的 v69.0。 量角器是 5.4.0。 Jasmine-core 是 3.4.0

相同的 e2e 测试适用于 Chrome。 我的单元测试使用 Karma 启动并且在 Firefox 中没有问题。

存储库位于https://github.com/admiralfeb/ggtavern.pub

量角器-firefox-ci.conf.js

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

/**
 * @type { import("protractor").Config }
 */
exports.config = {
    allScriptsTimeout: 11000,
    specs: [
        './src/**/*.e2e-spec.ts'
    ],
    capabilities: {
        browserName: 'firefox',
        marionette: true,
        firefoxOptions: {
            args: ['--headless']
        },
        'moz:firefoxOptions': {
            args: ['--headless']
        }
    },
    directConnect: true,
    baseUrl: 'http://localhost:4200/',
    framework: 'jasmine',
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        print: function () { }
    },
    onPrepare() {
        require('ts-node').register({
            project: require('path').join(__dirname, './tsconfig.json')
        });
        jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
        var junitreporter = new JUnitXmlReporter({
            savePath: require('path').join(__dirname, '../tests/e2e'),
            consolidateAll: true
        });
        jasmine.getEnv().addReporter(junitreporter);
    }
};

【问题讨论】:

    标签: angular protractor


    【解决方案1】:

    我确实有同样的问题,对我来说它是由 ng cli 生成的 afterEach 函数引起的: afterEach(async () => { // Assert that there are no errors emitted from the browser const logs = await browser.manage().logs().get(logging.Type.BROWSER); expect(logs).not.toContain(jasmine.objectContaining({ level: logging.Level.SEVERE, } as logging.Entry)); }); 当你删除它时,一切都很好。似乎Firefox的硒驱动程序无法向浏览器询问控制台日志。

    【讨论】:

    • 我发现从 cli 生成的测试的旧版本在 Firefox 中工作。我清除了较新的测试并用较旧的测试替换它们,现在 Chrome 和 Firefox 都可以工作(如果量角器会更新它们的 webdriver-manager 依赖项,那么我不必在每次安装后都执行npm explore protractor -- npm update webdriver-manager
    猜你喜欢
    • 2012-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-26
    相关资源
    最近更新 更多