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

194
Visualizações
puppeteer page.evaluate in module.exports

I just try to clean up the code, so I decided to create a new function and import it in main.js. I create new a.js and move everything from "it ( () => {})" to this file and here starts my problem. Page.evaluate just don't work, I try to console.log, alert something but didn't work. So anyone could help me clean that mess?

PS When we put code from a.js to main.js everything is fine.

main.js:

    const puppeteer = require('puppeteer');
    const pti = require('puppeteer-to-istanbul');
    const a= require('./a');
    describe("test", async () => { (...)
    it ('a.js', async ()=>{
            await a(page);

a.js


    const a = async (page) => {
        const 1= '#1'
    
        await page.waitForSelector(1, {visible: true}) 
        await page.click(1)
        await page.evaluate(async () => {
            let value = "Z"
            let clientPicker = document.querySelector('button[data-id="ctl00_CPH_Content__V_BPS_BankiProdukt__Q__Miejscowosc"]');
            clientPicker.click();
            let listOption = clientPicker.parentNode.querySelectorAll('li a > span')
            Array.from(listOption).find(item => item.innerText == value).click()
          }); (...) 
    }
    module.exports = a;

SOLVED: I had to add /* istanbul ignore next */

await page.evaluate(/* istanbul ignore next */ () => {
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