Casper.js 单击具有不同名称的按钮 ID

Casper.js Click on Button ID with Different Names

我正在尝试使用 casper.js 单击网页上的小项目符号(按钮)并截屏。

<div> == [=11=]
  <input type="image" name="ct100$body$uxDashboardList$ct100$dshButton" id="dshButton" title="Page 1" src="Images/bullet_green.png">
  <input type="image" name="ct101$body$uxDashboardList$ct100$dshButton" id="dshButton" title="Page 2" src="Images/bullet_green.png">
  <input type="image" name="ct102$body$uxDashboardList$ct100$dshButton" id="dshButton" title="Page 3" src="Images/bullet_green.png">
  <input type="image" name="ct103$body$uxDashboardList$ct100$dshButton" id="dshButton" title="Page 4" src="Images/bullet_green.png">
</div>

我可以使用以下方法在第一个着陆页上截屏:

var casper = require('casper').create();
var fs=require('fs');

casper.options.viewportSize = { width: 1920, height: 1080 };
casper.userAgent('Mozilla/5.0 (Windows NT 5.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36');
casper.start('https://websitenotdiscloseasitcontainsprivateinformationsandaspecialkey', function() {

    this.wait(10000, function() {
        this.click('ctl01$Body$uxDashboardList$ctl02$dshButton');
        casper.capture('page2.png');
   });
});

casper.run();

使用此代码 casper.js 不会截取任何屏幕截图(猜猜它找不到按钮?)

无法找到单击 ID 相同但名称不同的按钮的方法。

所以我在点击 link 后没有等待页面加载:

this.wait(5000, function() {
    this.click('input[type="image"][name="ctl00$Body$uxDashboardList$ctl02$dshButton"]');
   });
     this.wait(5000, function() {
         this.capture('test2.png');
  });

可能不够优雅,但确实有效