Skip to content

Instantly share code, notes, and snippets.

@boulabiar
Last active August 29, 2015 14:15
Show Gist options
  • Save boulabiar/d935bf82497d5fb91fb8 to your computer and use it in GitHub Desktop.
Save boulabiar/d935bf82497d5fb91fb8 to your computer and use it in GitHub Desktop.
var casper = require('casper').create();
casper.start('http://www.bibus.fr/horaires-station-navitia.aspx', function() {
this.echo(this.getTitle());
});
casper.run();
// fill form
casper.then(function(){
this.evaluate(function() {
ee= document.getElementById("ctl00_Centre_UC_Horaires1_ddlLigne");
$(ee).blur();
document.querySelector(".ctrDropDown").selectedIndex = 4;
$(".ctrDropDown").change();
setTimeout(function(){
document.querySelector("#ctl00_Centre_UC_Horaires1_ddlDirection").selectedIndex = 2;
$("#ctl00_Centre_UC_Horaires1_ddlDirection").change();
document.querySelector("#ctl00_Centre_UC_Horaires1_ddlArret").selectedIndex = 46;
$("#ctl00_Centre_UC_Horaires1_ddlArret").change();
setTimeout(function(){
document.getElementById("ctl00_Centre_UC_Horaires1_lbRechercher").click();
}, 100);
}, 1000);
});
});
// get the time
casper.wait(3000, function() {
if (this.exists('table')) {
this.echo('table exists');
this.echo(this.getElementInfo('table').html);
}
//this.captureSelector('table.png','table');
this.capture('screenshot.png');
});
@boulabiar
Copy link
Author

Pour automatiser, il suffit d'ajouter une boucle et jouer sur les valeur de selectedIndex
.selectedIndex = valeur ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment