简体   繁体   English

警告失败量角器

[英]Fail Protractor on warnings

I looked through the protractor API and reference conf.js but I couldn't find any documentation on how to fail protractor on warnings or how to turn warnings into errors.我查看了量角器 API 并参考了 conf.js,但我找不到任何关于如何使量角器在警告上失败或如何将警告转换为错误的文档。

Is either of those possible?有可能吗?

There is nothing built-in in Protractor to treat warnings as errors. Protractor 中没有任何内置功能可以将警告视为错误。

You can redefine the Protractor's log.warn() and throw an error instead of logging a warning:您可以重新定义量角器的log.warn()并抛出错误而不是记录警告:

onPrepare: function () {

    var logger = require('protractor/lib/logger.js');
    logger.warn = function (message) {
        throw message;
    };
},

Works for me.为我工作。


Also, note that:另外,请注意:

WARNING - more than one element found for locator ... - the first result will be used警告 - 为定位器找到了多个元素...... - 将使用第一个结果

This warning can easily be fixed by replacing the:可以通过替换以下内容轻松修复此警告:

element(...)

with:和:

element.all(...).first()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM