I am new in Casperjs and I would like do dinamic testing depending on external data sources. But, I am experiencing some problems with the loops.
This is my code:
var url = ['http://google.com/','http://www.as.com'];
casper.test.begin('PruebaLoop', function (test) {
casper.start('about:blank',function() {
});
casper.then(function() {
casper.viewport(1024, 768);
//casper.echo(casper.getTitle());
});
console.log('url.length: ' + url.length)
for (i = 0; i < url.length; i++) {
casper.thenOpen(url[i], function() { // open that link
console.log('i: '+i);
});
casper.wait(5000, function() {
this.echo("I've waited for a 5 seconds.");
});
casper.then(function() {
casper.capture('url'+i+'.png');
});
}
casper.run(function() {
casper.echo('Test completado');
casper.test.done();
});
});
From debugging, I always get 2 as the result. I don't know why. Could you please offer me some help?
Thanks a lot!