Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to run phantomas locally #112

Closed
shama opened this issue Oct 31, 2013 · 8 comments
Closed

Ability to run phantomas locally #112

shama opened this issue Oct 31, 2013 · 8 comments
Milestone

Comments

@shama
Copy link

shama commented Oct 31, 2013

Hi! Thanks for this fantastic library! It would be great if I could install and use phantomas locally. This way other modules could use this library as a dependency and extend it on npm. My use case is I'm writing a grunt plugin for performance metrics.

The other benefit is installing is more idiomatic to node.js where users are only asked to do:

npm install
npm test

with a package.json like:

{
  "scripts": {
    "test": "phantomas --url http://phantomjs.org"
  },
  "dependencies": {
    "phantomas": "0.8.1"
  }
}

I'd be happy to help out implementing this so it runs both globally and locally. Thanks!

@macbre
Copy link
Owner

macbre commented Oct 31, 2013

@shama, thanks for your interest in extending phantomas!

Please shed some light on "This way other modules could use this library as a dependency and extend it on npm.". I'm curious to know how can node.js based code use phantomas code (without running it via PhantomJS).

npm test example is really nice use case :)

I'm looking forward to see your implementation.

@shama
Copy link
Author

shama commented Nov 1, 2013

Awesome! Glad to hear. I'll get started on an implementation to propose.

Here is how we're using phantomjs locally with Grunt: https://github.com/gruntjs/grunt-lib-phantomjs Our qunit and jasmine task use that library to run tests. It dynamically creates a tmp script file and spawns a locally installed phantomjs to run it. We have it tested across osx, windows, linux on node v0.8 and v0.10 currently.

@LaurentGoderre
Copy link
Contributor

Hey @shama I did some local phantomjs as well. Need any help working on this?

@macbre
Copy link
Owner

macbre commented Dec 3, 2013

Random idea, guys. What do you think about phantomas module for NodeJS that will expose an API for spawning phantomas process and getting results?

var phantomas = require('phantomas');

phantomas(url, options, function(err, data) {
  // callback or promise pattern
});

@LaurentGoderre
Copy link
Contributor

It would be a good idea.

@Libida
Copy link

Libida commented Apr 7, 2015

Hi,

phantomas doesn't work locally for me:

d:\Buildkit>phantomas --url http://localhost:8001/ --verbose
15:47:29.987 phantomas v1.10.0:
C:/Users/maryia_sinkevich/AppData/Roaming/npm/node_modules/phantomas/
15:47:29.988 Options: {"version":false,"V":false,"help":false,"h":false,"colors":false,
"disable-js":false,"no-externals":false,"progress":false,"silent":false,
"spy-eval":false,"verbose":true,"v":true,"scroll":false,"film-strip":false, "analyze-css":false,
"page-source":false,"reporter":"plain","R":"plain","format":"plain","timeout":15,
"url":"http://localhost:8001/","user-agent":"phantomas/1.10.0 (PhantomJS/1.9.8; win32 x64)"}
...
15:47:30.044 req: <http://localhost:8001/>
15:47:30.044 Event send emitted
15:47:30.045 Event pageOpen emitted
15:47:30.045 Timeout set to 15 sec
15:47:30.046 Page loading started
15:47:30.046 Event loadStarted emitted
15:47:30.092 Loading progress: 10%
15:47:30.092 Event progress emitted
15:47:34.073 Event onResourceReceived emitted
15:47:34.074 Blocked request by phantomjs: <http://localhost:8001/>
15:47:34.074 Event abort emitted
15:47:34.075 recv: "start" stage not registered for <http://localhost:8001/>!
15:47:34.075 contentLength missing: {"url":"http://localhost:8001/"}
15:47:34.076 recv: HTTP 200 <http://localhost:8001/> [undefined]
15:47:34.076 Event recv emitted
15:47:34.076 Event metric emitted
15:47:34.077 Event metric emitted
15:47:34.077 Time to first byte: set to NaN ms for #1 request to <http://localhost:8001/> 
(HTTP 200)
15:47:34.077 Time to last byte: set to 4030 ms
15:47:34.077 Event responseEnd emitted
15:47:34.078 Block domains: assuming "localhost" to be the main domain
15:47:34.078 Event metric emitted
15:47:34.078 Performance timing: responseEnd = 1428421654078
15:47:34.078 Event milestone emitted
15:47:34.083 Page loading finished ("fail")
15:47:34.083 Event loadFailed emitted
15:47:34.083 Exiting with code #254 (Page loading failed)!
15:47:34.083 Event exit emitted phantomas: (254) Page loading failed
15:47:34.097 phantomas scope injected

Could you please help in resolving this issue.
Timeout increasing didn't help.

@macbre
Copy link
Owner

macbre commented Apr 7, 2015

What does curl -sv http://localhost:8001 > /dev/null shows?

@Libida
Copy link

Libida commented Apr 8, 2015

Thank you for your response.

d:\Buildkit>curl -sv http://localhost:8001 > /dev/null
The system cannot find the path specified.

My mistake, didn't observe that server was stopped.
Now everything is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants