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

293
Visualizações
puppeteer UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getProperty' of undefined

I got the following error in a JavaScript program with puppeteer: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getProperty' of undefined

I've checked several times but the element exists and can be found through the XPath. Here's my code

const puppeteer = require('puppeteer');

async function scraping(url, username, password) {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto(url, { waitUntil: 'networkidle0' });

    const [loginTitle] = await page.$x('/html/body/div[1]/div[2]/div/div/div[1]/h3');
    const loginTitleTxt = await loginTitle.getProperty('textContent')
    const loginTitleRawTxt = await loginTitleTxt.jsonValue();

    const [usernameInputField] = await page.$x('//*[@id="form-username"]/input');
    usernameInputField.type(username);

    const [passwordInputField] = await page.$x('//*[@id="form-password"]/input');
    passwordInputField.type(password);

            await page.evaluate(() => {
        document.evaluate('/html/body/div[1]/div[2]/div/div/div[2]/form/div[3]/div[1]/button', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click();
    });
    
    // Here is the error
    const [planTitle] = await page.$x('/html/body/center[1]/p[1]/table/tbody/tr[2]/td');
    const planTitleTxt = await planTitle.getProperty('textContent')
    const planTitleRawTxt = await planTitleTxt.jsonValue();
    
    console.log(planTitleRawTxt);
    browser.close();
}

scraping('https://hereisttheurl.net/abc.html', 'aa.bb', '123');

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