I'm trying to set up remote debugging with PhantomJS, without much luck. I am following the instructions at https://github.com/ariya/phantomjs/wiki/Troubleshooting. I have a little program named debug.js
:
var system = require('system' ), fs = require('fs'), webpage = require('webpage');
(function(phantom){
var page=webpage.create();
function debugPage(){
console.log("Refresh a second debugger-port page and open a second webkit inspector for the target page.");
console.log("Letting this page continue will then trigger a break in the target page.");
debugger; // pause here in first web browser tab for steps 5 & 6
page.open(system.args[1]);
page.evaluateAsync(function() {
debugger; // step 7 will wait here in the second web browser tab
});
}
debugPage();
}(phantom));
Now I run this from the command line:
$ phantomjs --remote-debugger-port=9001 --remote-debugger-autorun=yes debug.js my.xhtml
The console.log
messages are now displayed in the shell window. I open a browser page to localhost:9001
. It is at this point that the documentation says "get first web inspector for phantom context" However, I see only a single entry for about:blank
. When I click on that, I get an inspector for the irrelevant about:blank page, with the URL http://localhost:9001/webkit/inspector/inspector.html?page=1
. The documentation talks about executing __run()
, but I can't seem to get to the page where I would do that; about:html
seems to contina a __run()
which is a no-op.
FWIW, I am using PhantomJS 1.9.1 under W8.
What am I missing?
The documentation says :
To run your script, simply enter the __run() command in the Web Inspector Console.
__run()
is not a no-op but just a wrapper to your script. You need to select Console tab first and then enter __run()
in the command window. If you are familiar with Chrome, it's fairly the same as for developpers tool.