While navigating a website that produces a substantial JSON response, I encounter an issue where the connection is closed before the complete response is received after triggering a click event:
casper.then(function li10() {
casper.click(SEARCH_BUTTON_CSS);
});
Even after waiting for the URL to show up, it doesn't seem to be enough:
casper.then(function li11() {
casper.waitForUrl(/\/search-results\/p\?/,
function() {
var search_url = casper.getCurrentUrl();
console.log('found search results, url = ' + search_url);
},
function() {
console.log('failed to find search results');
casper.exit();
},
10000);
});
So my question is: What can I reliably wait for to ensure that the JSON data has fully loaded before moving on to the next step?