I am facing a scenario where I need to retrieve the text of a web element using a promise and then extract a specific part of the string for further processing.
Which example, the one at the top or the bottom, should I use?
var id = element(by.binding('smsDetails.message')).getText().then(function(message){
var messageArray = msg.split("\n");
var indexPosition = messageArray[0].indexOf("ID");
id = messageArray[0].substr(indexPosition + 5, 10);
return id;
});
var id;
element(by.binding('smsDetails.message')).getText().then(function(message){
var messageArray = msg.split("\n");
var indexPosition = messageArray[0].indexOf("ID");
id = messageArray[0].substr(indexPosition + 5, 10);
});