How to remotely debug CasperJS from Chrome?
What are the steps to debug CasperJS scripts in Chrome? I am trying to debug my windows 8.1.
1) my test c: \ temp \ googletestin.js has:
debugger;
casper.test.begin('Google search retrieves 10 or more results',3, function suite(test) {
casper.start("http://www.google.com.br/", function() {
this.echo(">>Number 1");
test.assertTitle("Google", "Title home page google");
casper.echo(">>Number 2");
test.assertExists('form[action="/search"]', "find form search");
casper.echo(">>Number 3");
this.fill('form[action="/search"]', {
q: "casperjs"
}, true);
this.echo(">>Number 4");
casper.capture('test.png', undefined, {
format: 'png',
quality: 75
});
})
casper.run(function() {
test.done();
});
});
2) open cmd.exe
3) execute command line
>casperjs test c:\temp\googletesting.js --remote-debugger-port=9222 --remote-debugger-autorun=yes
ps: the test runs through normally
4) open chrome and the field that url: http:localhost:9222
5) the page is empty
6) open console (f12) and execute: __run();
but nothing happens
source to share
In step 3, you need to pass the debugger parameters to CasperJS, not a script where it will be accessible via casper.cli
. You also must not allow script ( --remote-debugger-autorun=yes
) to auto-run , otherwise it will run before you can debug it. As you rightly said, you can open Chrome / Safari and invoke __run()
to run the script execution.
casperjs --remote-debugger-port=9222 test yourScript.js
source to share