I'm trying iterate in a grid where each line has an action link button. I need to click on this button and go back to the grid and click the button on the next line.
See the CasperJS script:
for(var i=1; i<lines.length; i++) {
var element = this.getElementInfo(x('//*[@id="elx"]/tbody/tr[' + i +']/td[1]'));
var item = x('//*[@id="gdvConsulta"]/tbody/tr[' + i +']/td[3]/a');
var model = {
'custom': element.text,
'item': item.text
};
// Click on item
casper.click(item);
this.waitForSelector(x('//*[@id="grid"]'),
function pass () {
utils.dump('ok');
var backbutton = x('//*[@id="back"]/a');
casper.click(backbutton);
},
function fail () {
utils.dump('error');
}
);
utils.dump('done line');
}
Note: the message 'done line' has been printed for all lines before the click on my first iterate of loop.
How to make a real waitForSelector()
without going to next iteration?