CasperJS is awesome but it's not posting to my localhost what my console output is.
casper.wait(5000, function () {
casper.wait(1000, function () {
casper.then(function(){
for (var i = 0 ; i < 10; i++) {
var description = casper.fetchText(x('//*[@id="acDataId-local'+i+'"]/a')); //*[@id="acDataId-local0"]/a
console.log(description);
var target_date = casper.fetchText(x('//*[@id="dtDataId-local'+i+'"]/text()[1]'));
console.log(target_date);
var target_location = casper.fetchText(x('//*[@id="veDataId-local'+i+'"]'));
console.log(target_location);
console.log(i, description)
casper.then(function () {
casper.open('http://localhost:1337/events', {
method: 'post',
data: {
'description': description,
'target_date': target_date,
'target_location': target_location,
},
headers: {
"stuff":"stuff"
}
});
});
}
this.echo('POST ' + i );
});
});
});
casper.run();
Console.log is outputting exactly when I want but it is only posting the last item. I tried to add casper.wait in a variety of places but it didn't seem to help!