5 comments

[ 18.8 ms ] story [ 136 ms ] thread
Can anyone compare this to Selenium? Which do you prefer to use and why?
If you have a single-page JavaScript application, I would use CasperJS. The JavaScript engines are functionally almost equal if you use frameworks. The usual "clickAndWait" Selenium verb doesn't work with single-page apps since it expects the page to reload. See http://stackoverflow.com/questions/3703458/click-clickandwai... Obviously, this is not a problem with CasperJS and PhantomJS, they are much more tightly integrated with the browser, and you can click elements by ID without needing the ugly "waitForElementPresent" hack. The only issue I've had with CasperJS/PhantomJS is that you can't reliably test Emscriptened apps since the QtWebkit version is old and doesn't have Float64Array support.

If you want to test for layout issues, or if you need something more stable, use Selenium. PhantomJS 1.8 has WebDriver support: http://phantomjs.org/release-1.8.html If you want headless Selenium.

For nodeheads who also do web development, this is a great tool. The syntax is incredibly familiar, and tests are executed quickly.

Selenium is a better tool to test cross-browser compatibility, but if you're just testing your program logic PhantomJS/CapserJS can get you there (IMO) a lot quicker & easier. JS devs can get moving quite quickly.

For scraping, how does this compare to pjscrape? (http://nrabinowitz.github.com/pjscrape/)
Well CasperJS is primarily a testing framework. But PJScrape and CasperJS are both tiny in comparison to PhantomJS. It doesn't matter much which one you choose. I'd go with CasperJS since it's more popular.