1

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

1 Answer 1

1

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); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.