Trying to scrape a JS-heavy, paginated list.
I can see the number of total pages and so therefore I know how many times I will need to run .waitForSelectorTextChange()
. This doesn't work:
casper.withPopup(/NewInventoryManager/, function() {
var target = 3;
for (var i = 0; i < target; i++) {
this.click('#btnNext'); // Click next and initiate a loading.gif modal
casper.waitForSelectorTextChange('#some_div', function() {
this.echo('Here I can parse the now updated DOM.');
}, function() {}, 35000);
}
});
It runs through the script all at once and sets the .waitForSelectorTextChange
functions all at once, when the initial click causes the DOM to change.
How can I add a dynamic number of steps inside the script programmatically? It seems to be working, sort of. How do I make them go one after the other?