How do I assert .containsText with case insensitive in Nightwatch.js?

774 views Asked by At

How do I assert .containsText with case insensitive in Nightwatch.js? For example I search for 'odin sphere' on google. There are a lot of possibilities for the search result, like 'Odin Sphere' 'odin sphere' 'ODIN SPHERE' etc etc I would like to assert with just 'odin sphere'. Here's the code I wrote.

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!
1

There are 1 answers

0
Maxim On

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

Usage:

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