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

80
Vistas
page.evaluate returns null document

Below is the phantomjs code

page.open('https://onli**************uickpay.html', function (status) {
    if (status !== 'success') {
        console.log('Unable to access network')
    } else {
        console.log('internet is working');
        var ua = page.evaluate(function (loanID) {
            var loanIDSplit = loanID.split('/');
            document.getElementById("txtBranchCode").value = loanIDSplit[0];
            document.getElementById("txtType").value = loanIDSplit[1];
            document.getElementById("txtLoanNumber").value = loanIDSplit[2];
            document.getElementById("btnLoanNoSearch").click();
        }, loanID);

    console.log(util.inspect(document, false, null));
    setTimeout(function () {
        var html = page.evaluate(function () {
            var table = document.getElementById('tblQpLoanNo');
            table.getElementsByClassName('odd')[0].click();
            document.getElementById("LoNoPayButton").click();
            return document;
        });
        page.render('/home/ubuntu/github.png');
        console.log('is the value of document'+html);
    }, 3000);

    setTimeout( function (){
      var release_amount = page.evaluate(function () {
      var table = document.getElementById('tblQpPayment');
      var row = table.getElementsByClassName('odd')[0];
      var payableAmount = row.getElementsByTagName('td')[3].textContent;
      return payableAmount;
  });

     console.log("release amount value is "+release_amount);
     // system.stdout.write("$" + releaseAmount);
     // system.stdout.write("$" + loanID);
     phantom.exit();
}, 10000);
}

when the above peace of code runs, the html value that is logged is showing up null

It works perfectly with phantomjs in macosx but when I have deployed it to ubuntu server it is not working. I made sure I am using phantomjs that supports linux

The first page.evaluate works fine, where as the next page.evaluate after 3 seconds timeout is not working, I have wasted enough time on debugging and finally asking over here, If some one had same issue or if some information is missing please feel to ask me.

what can be the reasons for document being null, that means there is some problem in evaluating the html page

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You cannot return document from page.evaluate because, according to the docs

Closures, functions, DOM nodes, etc. will not work!

If you want to get the whole html of the page, try a built-in page.content variable:

console.log(page.content);
over 4 years ago · Santiago Trujillo Denunciar
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