vendredi 7 août 2020

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;
}

Aucun commentaire:

Enregistrer un commentaire