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

215
Visualizações
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 à 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