我有以下HTML代码:
<tr class="job_summary_a">
<td><input type="CHECKBOX" name="job_id" value="20180601054414"></td>
<td> </td>
<td><a href="/test/?sec=job&subsec=view_job&job_id=20180601054414&job_folder=TT">20180601054414</a></td>
<td> </td>
<td>Test case 01</td>
<td> </td>
<td>Network test</td>
<td> </td>
<td>06/01/2018 05:44:14</td>
<td> </td>
<td>Completed</td>
</tr>
我在点击带有casperjs的复选框时遇到问题! 我现在的casperjs代码是:
var jobCheck = casper.evaluate(function () {
return [].map.call(__utils__.findAll('table tr td:nth-child(1)'), function (e) { return e.innerHTML; });
});
var jobID = casper.evaluate(function () {
return [].map.call(__utils__.findAll('table tr td:nth-child(3)'), function (e) { return e.innerHTML; });
});
var jobsTitle = casper.evaluate(function () {
return [].map.call(__utils__.findAll('table tr td:nth-child(5)'), function (e) { return e.innerHTML; });
});
var link = ""
var count = 0
for (var i = 1; i < rows; i++) {
console.log('Checking...row: ' + i + '...' + jobsTitle[i] + '...found');
link = JSON.stringify(jobID[i + 1]);
job = link.match(/job_id=(\d+\S\d+)/)[1];
console.log('Job ID: ' + job);
if (job === default_id) {
console.log('skipping!');
}
else {
console.log('marked to remove...jobId:' + job);
var sel = 'input[value="' + job + '"]';
var name = this.evaluate(function(job) {
document.querySelector(sel).click();
}, job);
console.log("Name-> " + name);
};
count = count + 1;
};
console.log('Total jobs found:' + count);
this.click('input[value="Delete"]');
但是,当我运行这个脚本时,我总是得到:
Checking...row: 232...Test case 01...found
Job ID: 20180601054414
marked to remove...jobId:20180601054414
**Name-> null**
Total jobs found:80
waiting...10s
始终显示Name为null!因此querySelector找不到sel(ector)=&gt;的click对象。 'input[value="' + job + '"]'
。
由于“删除”单击正在显示错误消息“未选择任何作业”。
复选框的问题在哪里??
先谢谢。