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

211
Vistas
Returning a node from puppeteer page.evaluate()

I am using puppeteer in my node project to check the number of img tag under a div, and I plan to achieve this by getting the nodelist from DOM and convert it to array so that I can easily filter the information.

But just to try it out first, I want to access an element first instead of a nodelist.

I don't understand why the return value (that being assigned to carousellNodeList) is undefined. I've checked the value I passed into page.evaluate(), which is IDls('photoCarousell'), and it is correct : "#app > div > div:nth-of-type(2) > div > div:nth-of-type(2) > div > div:nth-of-type(4) > div:nth-of-type(2) > div > div:nth-of-type(9) > div > div > div"

                async function getDOMImgCount(){
                    let carousellNodeList = await page.evaluate((photoCarousellStr:string)=>{
                        return document.querySelector(photoCarousellStr) as HTMLElement
                        
                    }, IDls('photoCarousell'))
                    let nodeListArr = Array.from(carousellNodeList);
                    
                }
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