I'm facing a challenge in storing the value of browser.executeScript within a local variable in my it block. In some cases, it returns null which is not desired.
I've experimented with different approaches but haven't found a reliable solution yet
browser.executeScript('$("txtName").css("border-left-color");').then(function (color) {
console.log("Color value is: " + color);
});
In addition to that
function returnColor() {
var result = browser.executeScript('$("#txtName").css("border-left-color");');
return result;
}
function getColorCode() {
var result = returnColor().then(function(data) {
console.log("Output is: " + data);
return data;
});
return result;
}
I'm using this code in my spec as follows:
iit('', function() {
browser.executeScript('$("txtName").css("border-left-color");').then(function (color) {
console.log("Color value is: " + color);
});
returnColor();
});
I would greatly appreciate any guidance on how to resolve this issue effectively.