Skip to content

Any way to see logging or console for script being run? #15

@zakfrazier

Description

@zakfrazier

I'm having difficulty trying to debug the script I'm executing from rails:

Phantomjs.run('./public/javascripts/thirdScreenCapture.js', 'email', 'password')

This then runs my thirdScreenCapture.js:

var webPage = require('webpage');
var page = webPage.create();

var args = require('system').args;
var email = args[1];
var pass = args[2];
var url = args[3];

page.viewportSize = { width: 1920, height: 1080 };
page.open('http://localhost:3000', function start(status) {
  var email = args[1];
  var pass = args[2];
  page.evaluate(function (email, pass) {
    document.querySelector('input[id=user_email]').value = email;
    document.querySelector('input[id=user_password]').value = pass;
    document.querySelector('form[id=new_user]').submit();
  }, email, pass);
  page.onLoadFinished = function(status) {
    console.log('Status: ' + status);
    window.setTimeout(function () {
      page.render('./public/appPage.png');
      phantom.exit();
    }, 3000);
  };
});

This works correctly from command line:

phantomjs public/javascripts/thirdScreenCapture.js email@email.com password http://localhost:3000/

But when from the controller the rails server hangs and nothing is produced. I just need to somehow access the console/logging for the phantomjs code being run. Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions