trouble with once
Hey, So i've been playing with this for two days, running into issues with once. The basic idea i'm trying to achieve is to detect a redirect on page load and exit out of the flow. When i put once after open i get: TypeError: Cannot read property 'render' of null When i put once at the end of the chain i get: TimeoutError: operation timed out
return pha
.viewport(1360, 960)
.open('http://' + link[0] + link[1])
.once('onLoadFinished', function(status) {
if(status === 301){
console.log('redirect')
reject();
}
resolve();
})
.screenshot(cleanSlashes + '.png')
.catch(function (e) {
console.log('error in scrapurl', e)
})
.finally(function () {
pha.exit();
console.log('finally! single url');
});
Have you tried calling .once before .open? I think you need to be listening for onUrlChanged instead, I'm not sure but onLoadFinished might only be called once the final page has loaded. Alternatively you could get the URL of the final page and check if it differs from the URL you specified.
when i do that i get another error : node : Unhandled rejection TypeError: expecting an array, a promise or a thenable At line:1 char:1