Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can I Debug PhantomJS Javascript Tests?

I am using Selenium and PhantomJS to do integration testing on my web app.

When something goes wrong, how do I debug the Javascript?

Can I connect with Firefox Developer Tools using Valence?

Note: I already save a screenshot and the page source when the test fails. What I want to do now is set break points and step through the code.

like image 358
opticyclic Avatar asked Aug 14 '26 03:08

opticyclic


1 Answers

You may be able to use node-inspector for that. However, I'd recommend using an actual browser for debugging. PhantomJS is a headless browser, and well suited for the job when you need a non-intrusive and fast browser, but otherwise I don't see any point in using it.

EDIT

Just looked at the PhantomJS documentation, and found this:

Remote Debugging

Remote debugging permits inspection of the script and web page via another WebKit-based browser (Safari and Chrome). This is achieved by launching PhantomJS with the new option, as in this example

phantomjs --remote-debugger-port=9000 test.js

After that, open Safari/Chrome/Chromium and go to the URL http://ipaddress:9000. If you executed the phantomjs command on the same machine, it will be http://127.0.0.1:9000

like image 171
Merott Avatar answered Aug 15 '26 18:08

Merott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!