CasperJS is a navigation scripting and testing utility for PhantomJS that allows testing of web pages and user interactions. It provides functions for navigation, clicking elements, filling forms, taking screenshots, and assertions. CasperJS runs quickly without a browser UI and allows debugging through verbose mode, capturing screenshots, and monitoring network requests and console logs. Tests can be refactored and common functions extracted to improve maintainability.
3. Web UI testing framework
Similar to Selenium Watir
Built on top of PhantomJS
Started around Sep 2011
3329 stars on Github
What’s CasperJS?
4. Why Casper?
Fast
No browser UI
Webkit based
Execution Speed
Write front end UI testing using JS
Did I mention how fast test runs?
5. How to install and run
Requirements: python + phantomJS
Available on Windows, OSX, Linux
Install
OSX: $ brew install casperjs --devel
Node: $ npm install -g casperjs
Run
$ casperjs test mytest.js
8. WTF is then()?
“then() basically adds a new navigation step in a stack. A step is a javascript
function which can do two different things:
- waiting for the previous step - if any - being executed
- waiting for a requested url and related page to load”
Niko, Creator of CasperJS
Source: http://stackoverflow.com/questions/13785670/passing-variable-from-this-evaluate-to-casper-then
16. Advanced topics
1. Setup/tear down
2. Support for file downloads, HTTP auth
3. Support for browser back/forward, scroll, reload, viewport site
4. Support for page events, alerts handling
5. Support for Continuous Integration
a. Jenkins XUnit output
$ casperjs test mytest.js --xunit=outcome.xml
b. GruntJS
6. Support for HTTPS
$ casperjs tumblr.js --ssl-protocol=any
7. Weak support for Drag and Drop
17. About me+us
Author: Herve Vu Roussel (see source at GitHub)
Find me at: hroussel@gmail.com
This presentation was made for Javascript Ho Chi Minh City meetup group
You can find us at:
http://www.meetup.com/JavaScript-Ho-Chi-Minh-City/
https://www.facebook.com/JavaScriptHCMC
https://plus.google.com/u/0/communities/116105314977285194967
http://www.slideshare.net/JavascriptMeetup