0

I want to iterate over the tr on a table using casper, but i cannot get the counter inside the evaluate function, i tried replacing the variable with a fixed number and it works.

var i =0;
for(i=1;i<amount;i++) {

var identifier = this.evaluate(function(i) {

return $("#div_identifiers_result > tr:nth-child("+i+") > td:nth-child(1)").parent().data('name'); 
});

this.echo(identifier ,'info');

how can i make the scope inside evaluate to see that i counter?

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
gabriel mellace
  • 229
  • 5
  • 15

1 Answers1

1

Try this:-

var identifier = this.evaluate(function(i) {
  return $("#div_identifiers_result > ..." + i + "...").parent().data('name'); 
}, i);

Anything inside evaluate is sandboxed and you will need to pass in any params you want to use inside

Rippo
  • 22,117
  • 14
  • 78
  • 117