【问题标题】:How to display in the nightwatch.js report all the outputs that appears in the console如何在 nightwatch.js 报告中显示控制台中出现的所有输出
【发布时间】:2019-06-20 18:31:19
【问题描述】:

在一些 nightwatch.js 测试中,我使用 console.log 打印一些变量值或 cmets。我想知道是否有办法在 nightwatch.js 报告中打印控制台的 console.log,因为只有 nightwatch 命令/断言可见。 我想做的是显示一个包含所有结果的报告,就像我在控制台中运行测试时一样。 提前谢谢你

【问题讨论】:

    标签: javascript nightwatch.js


    【解决方案1】:

    大部分命令都有msg(可选)参数,

        this.demoTest = function (browser) {
                 const msg = "We have passed the test"
                 browser.assert.visible(".testElement",msg);
    
            };
    

    代替

    v Testing if .testElement is visible
    

    它会打印出来

    v We have passed the test
    

    或

     x We have passed the test
    

    【讨论】:

    • 在这种情况下,可以作为注释使用,例如,.getAttribute('#register-form > .box div:nth-child(6)','textContent', function (name){ if( i == 1){ console.log('--> First click done on ' + name.value); browser.getAttribute('.subscription-total','textContent', function (kz){ console.log(kz.value); }) } 这个 console.log 将取决于 name.value 和 kz.value
    • 当我想写评论时,您的回答会对我有所帮助,但如果我想从门户打印一些名称/单词,那将不起作用。是否有任何 Nightwatch.js 命令可以替代 console.log('msg'); ?
    • 这个例子并不完全正确。在断言失败的情况下,输出将如下所示... × 我的自定义消息在 5000 毫秒内 - 预期“可见”但得到:“无法定位元素”(5185 毫秒)
    猜你喜欢
    • 1970-01-01
    • 2020-11-10
    • 1970-01-01
    • 2016-05-03
    • 2016-01-10
    • 1970-01-01
    • 2023-02-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多