CasperJS constantly checks if a selector exists
I am doing some scraping with casperjs and while the script is running, I also have to check if the technical difficulty page appears. This page can appear at any time while browsing the site, so I can't just put one test at the beginning, it has to be tested constantly. Is there a way in CasperJS / PhantomJS, like a listener or something?
The following should start:
casper.checkIfThereIsTechError = function() {
return casper.evaluate(function() {
return __utils__.exists({
type: 'xpath',
path: '//a[@href="......'
});
});
};
+3
source to share