Hi,
I new to CasperJS and PhantomJS, and put together
var casper = require('casper').create();
var links;
function getLinks() {
// Scrape the links from top-right nav of the website
var links = document.querySelectorAll('ul.navigation li a');
return Array.prototype.map.call(links, function (e) {
return e.getAttribute('href')
});
}
casper.start('http://infraworklist.se.com/worklist/index.html');
casper.then(function () {
links = this.evaluate(getLinks);
});
casper.run(function () {
for(var i in links) {
console.log(links[i]);
}
casper.done();
});When I run this I get
shell$ casperjs --verbose --log-level=debug t1.js
[info] [phantom] Starting...
[info] [phantom] Running suite: 3 steps
[debug] [phantom] opening url:
http://infraworklist.se.com/worklist/index.html, HTTP GET
[debug] [phantom] Navigation requested: url=
http://infraworklist.se.com/worklist/index.html, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "
http://infraworklist.se.com/worklist/index.html"
[debug] [phantom] Successfully injected Casper client-side utilities
[debug] [phantom] start page is loaded
[info] [phantom] Step anonymous 3/3
http://infraworklist.se.com/worklist/index.html (HTTP 200)
[info] [phantom] Step anonymous 3/3: done in 49651ms.
[info] [phantom] Done 3 steps in 49669ms
TypeError: undefined is not a constructor (evaluating 'casper.done()')
/Users/stephenfitch/src/worklist_scrape_backlog/src/phantomjs:/code/t1.js:24
/Users/stephenfitch/src/worklist_scrape_backlog/src/phantomjs:/platform/casper.js:423 in checkStep
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "about:blank"
Using CasperJS v1.1.4
Any clues on how to debug this or, if this is something in my site javascript?
Thanks, Stephen