这通常会导航到我这边的第二页。试试看,你还可以保存屏幕截图,以便进行更多的调试。
var casper = require('casper').create();
var url = 'https://www.marchespublics.gov.ma/index.php5?page=entreprise.EntrepriseAdvancedSearch&AllCons&EnCours&domaineActivite=1.15';
casper
.start(url, function() {
this.echo('Opened page ' + this.evaluate(function() {
return document.title;
}), 'INFO');
})
.then(function() {
if (this.exists('a[id="ctl0_CONTENU_PAGE_resultSearch_PagerTop_ctl2"]')) {
this.echo('the heading exists');
} else {
this.echo('Does not exist');
}
})
.thenClick('div.liens a#ctl0_CONTENU_PAGE_resultSearch_PagerTop_ctl2')
.wait(5000)
.then(function() {
this.capture('exit.png');
})
.run();
希望这有帮助!