Reputation: 2339
I'm new to casperjs,the evaluate function is not getting executed
casper.start('https://piedmont.taleo.net/careersection/2/moresearch.ftl?lang=en',function(){
casper.page.injectJs('/Users/manoj/apply_robots/jquery/jquery-2.1.4.min.js');
this.echo(this.getTitle());
this.wait(3000,processPage);
this.echo("before processPage");
});
function processPage()
{
this.echo("inside processPage");
var c = [];
c = this.evaluate(getJ);
this.echo(c);
}
function getJ(){
this.echo("inside getJ");
var jobs = [];
var names = $('table#requisitionListInterface\\.listRequisition tr[id$=row]');
__utils__.echo(names);
for (var i = 0, row; row = names[i]; i++) {
var $p = $.parseHTML(row.cells[1].innerHTML);
}
jobs.push(names);
return names.length;
}
Upvotes: 1
Views: 469
Reputation: 187
Probably
this.echo("inside getJ");
is the problem in your case, cause "this" in evaluate function is not the casper object, but probably the Window object. And since evaluate is executed in sandbox, it does not throw errors out.
Good luck
Upvotes: 1