ancestors.shift is not a function
I'm trying to get automated tests back up and running and having the following issue when I run a test.
The objective of the function is if the selector comes from a section of a page object selector will be an array of objects starting from the outermost ancestor (section), and ending with the element Join their selectors in order.
Error message:
Error while running "getElements" command: ancestors.shift is not a function
Function:
function getSelector(selector) {
let ancestors = selector;
if (typeof ancestors !== "string") {
selector = "";
let oElement = ancestors.shift();
while (oElement) {
selector += " " + oElement.selector;
oElement = ancestors.shift();
}
}
return selector;
}
The code which calls the getSelector function below:
selector(selector) {
return featureHelper.getSelector(selector);
}
getElement(result) {
if (result.status === 0 && Array.isArray(result.value)) {
for (let i = 0; i < result.value.length; i++) {
if (typeof result.value[i] === "object") {
result.value[i].ELEMENT =
result.value[i][Object.keys(result.value[i])[0]];
}
}
return result;
} else {
return result;
}
}
};