使用PhantomJS进行远程调试设置 [英] Getting remote debugging set up with PhantomJS
问题描述
我试图用PhantomJS设置远程调试,但是没有多大运气.我正在按照 https://github.com/ariya/phantomjs/wiki/Troubleshooting 中的说明进行操作一个>.我有一个名为debug.js
的小程序:
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
console.log
消息现在显示在外壳窗口中.我打开一个浏览器页面到localhost:9001
.此时文档说明为幻像上下文获取第一个Web检查器".但是,我仅看到about:blank
的单个条目.当我单击它时,我得到了一个无关的about:blank页面的检查器,其URL为http://localhost:9001/webkit/inspector/inspector.html?page=1
.文档讨论了执行__run()
的问题,但是我似乎无法到达执行该操作的页面. about:html
似乎将__run()
视为连续镜头.
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,我正在W8下使用PhantomJS 1.9.1.
FWIW, I am using PhantomJS 1.9.1 under W8.
我想念什么?
推荐答案
文档说:
要运行脚本,只需在Web中输入__run()命令即可. 检查器控制台.
To run your script, simply enter the __run() command in the Web Inspector Console.
__run()
不是空操作,而只是脚本的包装.您需要首先选择控制台"选项卡,然后在命令窗口中输入__run()
.如果您熟悉Chrome,则与开发人员工具完全相同.
__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.
这篇关于使用PhantomJS进行远程调试设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!