Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

214
Visualizações
How to return getTexts for array of elements with isExisiting

I am aiming to return a set of texts from a single locator that shares three elements and they are stored in an array of elements name selector (being selector storing three elements)and before it returns texts I want them to pass isExisting() flag but it throws "TypeError: selector.isExisting is not a function" if I remove isExisting part of code then it works fine and return the three text values. My code is:

  async function getTreeTexts(browser, sidebar, parentClass, treeClass, spanClass = 'caption') {
    //await browser.ideOpenSidebar(sidebar)
    var cl = c => c ? '.' + c : '';
    var selector  = await browser.$$(`${cl(parentClass)} .ace_tree${cl(treeClass)} .tree-row span${cl(spanClass)}`);
    await browser.ideOpenSidebar(sidebar)
    await selector.isExisting().then(async function (exists) {
        if (exists) {
        // Depending on the number of matches, items can be a string or an array of strings. Coerce to array.            
            let configs = [];
            for (let element of selector) {
                try {
                    let text = await element.getText();
                    configs.push(text);
                } catch (err) {
                    configs.push('[deleted]');
                }
            }
            return configs;
        } else {
            return [];
        }
    });
}

Can someone please assist me here if I am doing something wrong? (my guess is, isExisiting() not handling all three elements at the same time)

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda