For below protractor mocha test cases, greeting.getText() will always return
below result instead of the string. Could anyone give me clue on this?
describe('angularjs home', function () {
it('Should welcome a user', function (done) {
browser.get('http://www.angularjs.org');
element(by.model('yourName')).sendKeys('tanshuai');
var greeting = element(by.binding('yourName'));
console.log(greeting.getText());
expect(greeting.getText()).to.eventually.equal('Hello tanshuai!');
});
});
The console.log output================
ElementFinder {
browser_:
ProtractorBrowser {
controlFlow: [Function],
schedule: [Function],
setFileDetector: [Function],
getExecutor: [Function],
................................
getId: [Function],
takeScreenshot: [Function] }
Protractor: element.getText() returns an object and not String
Looks like getText()
returns a promise and you need to resolve it. Check out the link above
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.