alexscheelmeyer / node-phantom

bridge to PhantomJS from Node.js
317 stars 117 forks source link

create page of undefined #125

Closed mt406 closed 8 years ago

mt406 commented 8 years ago

I am trying to run below code and getting error "ph.create page of undefined ". Please tell me where I am missing something.

var http=require('http'); var phantom=require('node-phantom');

var server=http.createServer(function(request,response){ response.writeHead(200,{"Content-Type": "text/html"}); response.end('Hello World'); }).listen();

phantom.create(function(error,ph){

        ph.createPage(function(err,page){
            console.log(err);
            page.open('http://www.google.com',function(err,status){
                console.log("opened site? ", status);

                server.close();
                ph.exit();
                done();
            });
        });
    });

The complete error log is : D:\Jscript\node\pageopen.js:12 ph.createPage(function(err,page){ ^ TypeError: Cannot call method 'createPage' of undefined at D:\Jscript\node\pageopen.js:12:7 at D:\Jscript\node\node_modules\node-phantom\node-phantom.js:65:6 at null._onTimeout (D:\Jscript\node\node_modules\node-phantom\node-phantom.js:43:5) at Timer.listOnTimeout as ontimeout