I’m working with Meteor 1.4.2.
I run meteor npm install --save phantomjs
and I’m trying to run the following code with no success. It hangs in an infinte:
“select: Invalid argument”
server/init.js
url = <Dynamic URL>
var Future = Npm.require( 'fibers/future' );
var future = new Future();
var phantomjs = require("phantomjs");
var spawn = require('child_process').spawn;
command = spawn(phantomjs.path, ['assets/app/driver.js' ,url]);
var str_phantom_output="";
command.stdout.on('data', function (data) {
str_phantom_output += data.toString();
});
command.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
command.on('exit', function (code) {
future.return(str_phantom_output);
});
future.wait();
return future.value;
private/driver.js
var system = require('system');
var page = require('webpage').create();
page.open(system.args[1], function (status) {
setTimeout(function(){
evaluatePage();
phantom.exit();
},5000);
});
function evaluatePage(){
var inputCount = page.evaluate(function(){
return document.documentElement.outerHTML;
});
}