I would like to count the number of, let's say, div elements with 'nice' class. I've got the selector
If you can use jquery its fairly simple:
var count = $('div.classname').length;
Found an SO Post that seems to explain using jquery with casperjs, I have no experience with casperjs so I can't help much there.