I am currently working with nodejs and phantomjs (using this bridge: https://github.com/sgentle/phantomjs-node/blob/master/samples/test_phantom.js) and my simple phantomjs function isn't working properly. I'm wondering if it is a compability error with phantomjs and nodejs, or am I just making a blatant phantomjs error? I am trying to grab the input form on the google homepage. Here is the relevant code:
phantom.create(function (ph) {
ph.createPage(function (page) {
page.open("https://www.google.com/", function (status) {
console.log("opened", status);
/*
Page is succesfully opened
*/
page.evaluate(function() {
var x; //meaningless code
function funny() {
var q = document.getElementById("gbqfq").value; //if q = document.title it works properly
return q;
}
x = funny();
return x;
},
function(result) {
console.log(result);
ph.exit();
});
});
});
The error I am receiving:
phantom stdout: TypeError: 'null' is not an object (evualuating 'document.getElementById("gbqfq").value')
Thanks much!