【问题标题】:How do I assert .containsText with case insensitive in Nightwatch.js?如何在 Nightwatch.js 中断言 .containsText 不区分大小写?
【发布时间】:2020-10-20 03:55:03
【问题描述】:

如何在Nightwatch.js 中声明不区分大小写的 .containsText? 例如,我在 google 上搜索“odinsphere”。 搜索结果有很多可能性,比如“Odin Sphere”“odin sphere”“ODIN SPHERE”等,我只想用“odin sphere”来断言。 这是我写的代码。

module.exports = {
    beforeEach: browser => {
        browser.url('https://www.google.com/')
    },
    after: browser => {
        browser.end()
    },
    'Search test': browser => {
        browser
            .setValue('input[name="q"]',['odin sphere',browser.Keys.ENTER])
            .waitForElementVisible('#res')
            .pause(5000)
            .verify.containsText('#res','Odin Sphere')
    }

}```

Thanks in advance!

【问题讨论】:

    标签: nightwatch.js nightwatch


    【解决方案1】:

    https://nightwatchjs.org/api/#assert-containsText

    用法:

    this.demoTest = function (browser) {
      browser.assert.containsText("#main", "The Night Watch");
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-06
      • 1970-01-01
      • 2017-06-16
      • 2011-10-14
      • 2020-04-08
      • 2013-03-23
      • 2012-12-01
      相关资源
      最近更新 更多