Reputation: 763
I need to save an attribute value to a variable to be sent to a later object to verify a picture I upload which gets a unique src id is accessible using the src attribute I obtain. Later a search through a list of pictures will be done to find that particular uploaded picture.
getPictureSrc: function() {
var el = $('img');
var uniqueId = el.getAttribute('src');
return uniqueId;
},
findPicture: function() {
browser.get('a different webpage then the upload page');
var findPic = getPictureSrc();
var allPics = $$('img');
helper.expectedConditions.isVisible(allPics.$(findPics));
},
However when I run this code, I do a console.log()
and it throws back the list of available commands. Not the source. However if I do an expect against some random value the src does show. So I guess there are two questions, how do I print an attribute value to console and how do I pass an attribute value from object to object. Thank you.
Upvotes: 1
Views: 213
Reputation: 473873
However when I run this code, I do a console.log() and it throws back the list of available commands.
getPictureSrc()
returns a promise. A promise is what you see printed on the console. If you need the actual value, resolve the promise explicitly:
getPictureSrc().then(function (src) {
console.log(src);
});
However if I do an expect against some random value the src does show.
This is the magic of the expect()
- it is patched (by jasminewd
package) to implicitly resolve promises before making an expectation. Having expect()
accepting promises is quite convenient.
Upvotes: 2