我正在用casperjs做一些抓取,同时运行脚本,我也应该测试是否有技术困难的页面出现。这个页面可以在浏览网站的时候随时出现,所以我不能只在一开始就进行一次测试,它应该持续进行测试。在CasperJS/PhantomJS中有像监听器之类的方法吗?
应该运行以下命令:
casper.checkIfThereIsTechError = function() {
return casper.evaluate(function() {
return __utils__.exists({
type: 'xpath',
path: '//a[@href="......'
});
});
};发布于 2014-12-16 14:31:38
在casper js中,一切都被表示为一个步骤。在每个步骤中,首先调用您的函数以检查错误
casper.then(
function(){
isErrorexists = casper.checkIfThereIsTechError()
if (!isErrorexists){
do what you want to do here...
}
}
)https://stackoverflow.com/questions/25521201
复制相似问题