Phantomjs 调试方法:
Phantomjs命令行: phantomjs [options] somescript.js [arg1 [arg2 [...]]]
关于调试的[options]:
关于调试的[options]:
--remote-debugger-port
开启调试模式并监听制定端口
--remote-debugger-autorun
在调试器中立即执行脚本(Yes/No)ex:
phantomjs --remote-debugger-port=9000 hello.js
脚本内容:
debugger;//放在开头 或者任意位置(当断点)
for (var i=0; i < 5; i++)
{
console.log('debugging in phantom js:' + i);
}
phantom.exit();
=============调试过程=============
step0:将上述脚本放在 d:\hello.js
step1:打开命令行执行
step2:打开chrome 输入 http://127.0.0.1:9000/ 回车phantomjs --remote-debugger-port=9000 d:\hello.js
step3:点击链接
step4:在Console中输入: __run() 回车
开始调试吧,若修改代码,则重复上述过程 (果然麻烦..)