Is there a console for PhantomJS?
console, javascript, phantomjs
Solution
There is an interactive mode (REPL) since version 1.5 almost a year ago. You just need to launch PhantomJS without any argument and it will immediately start in REPL mode.
Problem
I found this on github: https://github.com/gr2m/phantomjs-console But it is a bit crazy, having to write commands in a file, on one line only, which is then read, and deleted, and the output being in the terminal. I want a console like... ``` $ phantomjs --console phantom> console.log(typeof $) [Object Function] phantom> console.log("happy days") happy days phantom> ``` Is there anything like this? EDIT: Starting to understand why they did it in such a crazy way... From PhantomJS-Node: https://github.com/sgentle/phantomjs-node No really, how does it work? I will answer that question with a question. How do you communicate with a process that doesn't support shared memory, sockets, FIFOs, or standard input? Well, there's one thing PhantomJS does support, and that's opening webpages. In fact, it's really good at opening web pages. So we communicate with PhantomJS by spinning up an instance of ExpressJS, opening Phantom in a subprocess, and pointing it at a special webpage that turns socket.io messages into `alert()` calls. Those `alert()` calls are picked up by Phantom and there you go! The communication itself happens via James Halliday's fantastic dnode library, which fortunately works well enough when combined with browserify to run straight out of PhantomJS's pidgin Javascript environment. If you'd like to hack on phantom, please do! You can run the tests with cake test or npm test, and rebuild the coffeescript/browserified code with cake build. You might need to `npm install -g coffeescript` for cake to work.