peerigon / phridge

A bridge between node and PhantomJS
The Unlicense
519 stars 44 forks source link

Trying to page.open, but no joy #24

Closed paulxtiseo closed 9 years ago

paulxtiseo commented 9 years ago

Using phridge to run Phantom to login into a site and retrieve an attachment. This is done inside the SailsJS framework.

Running

sails.phridge
  .spawn()          
  .then(function(phantom) { 

    return phantom.run(function() {  
      console.log('run');
      page = webpage.create();
      page.open('https://commercialservices.freshservice.com/support/login', function(status) {
        console.log('hi');
        page.render('test.png');
      });
      console.log('run');
    });

  })
  .catch(function(e) {
    sails.log.info('catch');
    sails.log.error(e);
  })
  .finally(function(f) {
    sails.log.info('finally');
    sails.log.info(f);
  });

does not result in a console.log() or a page.render() inside the page.open(). However, I do see the two console.log('run') lines output to the screen. Running the same block of code inside page.open() directly in PhantomJS does produce a PNG. Am I doing something wrong?

PS: FWIW, the sails.phridge... line is equivalent to a require('phridge')

jhnns commented 9 years ago

Mhmm ... that code looks ok.

Does it also occur when not using sail.js? Can you replace the url with a local http server and check if phantom is requesting the page?

You can use this example and modify it to your use-case.

paulxtiseo commented 9 years ago

So, oddly, your example (inserted into a SailsJS app with very minor mods) worked but my code above does not. Any ideas why?

jhnns commented 9 years ago

Could you create an example repo where this code doesn't work? I think we need to isolate the problem...

jhnns commented 9 years ago

Close?

paulxtiseo commented 9 years ago

Yes. I have moved on to another approach, and so if I somehow circle back to this, I'll reopen or create a new ticket. Sorry for the inconvenience.

jhnns commented 9 years ago

No worries. :+1: