I'm facing some challenges with my nightwatch tests as I'm struggling to retrieve data from a webpage and display it on my console. Any guidance in the right direction would be greatly appreciated.
Every time I attempt to log the data to my console, it simply returns [object Object]. As a beginner in test automation, I haven't been able to find a solution by searching online. Below is the code snippet (testing site is Google's front page):
module.exports = {
tags: ['google'],
'Demo test Google' : function (client) {
client
.url('http://google.com')
.pause(500);
var msg = "---> : ";
client.expect.element('body').to.be.present;
client.getText("#gbw > div > div > div.gb_7d.gb_R.gb_le.gb_ee > div:nth-child(1) > a", function(result) {
client.expect.element("#gbw > div > div > div.gb_7d.gb_R.gb_le.gb_ee > div:nth-child(1) > a").text.to.equal("Gmail");
console.log(msg.toString()+result);
});
client.getValue("#tsf > div.tsf-p > div.jsb > center > input[type='submit']:nth-child(1)", function(result) {
client.expect.element("#tsf > div.tsf-p > div.jsb > center > input[type='submit']:nth-child(1)").to.have.value.that.equals("Sök på Google");
console.log(msg+result);
});
client.end();
}
};