Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

215
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda