My goal in the test code is to achieve the following:
it('Updates label text', function(done) {
page.testLabelText();
assert.equal(page.testLabelText().pageLabel, page.testLabelText().iFrameLabel);
done();
});
In my page object, here is testLabelText();
:
page.testLabelText = function () {
var pageLabel = function () {
return driver.findElement(By.css('#element')).getText().then(function(text) {
return text;
});
};
var iFrameLabel = function () {
return driver.findElement(By.css('#element')).getText().then(function(text) {
return text;
});
};
return {
pageLabel: pageLabel(),
iFrameLabel: iFrameLabel()
};
};
However, when printed to the console, this returns 'Undefined'...I am new to Javascript and although I have been able to do this in regular javascript, all my attempts with Selenium WebdriverJS promises have failed...