我无法使用casperjs下载页面中的PDF文件。以下是我的步骤:
我正在使用CasperJS进行点击。按钮单击工作完美但无法单击图像以下载文件。
这是我的代码:
casper.start().thenOpen("url", function() {
console.log("keeneland divison by handle");
casper.then(function(){
this.echo(" Load page ");
console.log("Setting Race Date :----------------"+casper.cli.get(0));
casper.evaluate(function(inputRaceDate){
console.log("Date :----------------"+inputRaceDate);
document.getElementById("ctl00_ContentPlaceHolder1_beginDate_I").value=inputRaceDate;
aspxETextChanged('ctl00_ContentPlaceHolder1_beginDate');
document.getElementById("ctl00_ContentPlaceHolder1_endDate_I").value=inputRaceDate;
aspxETextChanged('ctl00_ContentPlaceHolder1_endDate');
document.getElementById("ctl00_ContentPlaceHolder1_cmbLocs_LBI0T0").value="All Locations";
document.getElementById("ctl00_ContentPlaceHolder1_cmbTracks_I").value="All Tracks";
document.getElementById("ctl00_ContentPlaceHolder1_ddlReportBy").value="0";
/* document.getElementById("ctl00_ContentPlaceHolder1_ddlReportBy").value="1"; */
/* document.getElementById("ctl00_ContentPlaceHolder1_ddlReportBy").value="2"; */
document.getElementById("ctl00_ContentPlaceHolder1_btnSubmit").click();
});
});
});
casper.then (function () {
this.waitForSelector("ctl00_ContentPlaceHolder1_GridExport_XLSPdf}",
function pass () {
this.echo(" pdf load ");
document.getElementById('ctl00_ContentPlaceHolder1_GridExport_XLSPdf').click()
},
function fail () {
this.echo(" pdf load failed");
},
2000 // timeout limit in milliseconds
);
});
我无法在第二步中找到偶数ID。