Apparently, in Nightwatch, there's no 'document' or 'window' object.
There is a 'browser' object which seems to be similar.
Tried using .getElementById(), .remove(), .removeChild() and Nightwatch doesn't recognize the methods.
You have to use .execute() function to write document statements. In the below example I am using the querySelector to find the element and then asserting its innertext in the callback.
'Nightwatch JS Example': function(browser) {
browser.url('https://example.com').waitForElementVisible('body').execute(function() {
return document.querySelector(selector).innerText
}, [], function(result) {
this.assert.equal(result.value, 'Some text')
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With