捕获在CasperJS中不起作用

时间:2017-10-06 04:04:11

标签: javascript casperjs

希望你做得好,

目的:在页面完全加载时截取屏幕截图

尝试:已经尝试等待某些MS,并且在找到id时使用SS。 但它现在还不行......

             casper.waitFor(function StepOne() {
                casper.wait(25000, function () {
                    casper.echo('after 25 sec');
                    casper.capture('screenshots/SS1.png');
                });

                casper.waitForSelector('#Row1',
                function success() {
                    casper.CustomEcho('ID FOUND');
                    casper.capture('screenshots/SS2.png');
                },
                function fail() {
                        console.log("oops! ID is not Found..!.");
                    }
                );
                return true;
            }, function StepTwo() {
                casper.capture('screenshots/I_Am_in_Then_SS3.png');
                casper.CustomEcho('*****_exit_*********');
                casper.exit();
            });

感谢高级!

1 个答案:

答案 0 :(得分:0)

casper.wait(25000, function() {
  casper.echo('after 25 sec');
  casper.capture('screenshots/SS1.png');
});

casper.waitForSelector('#Row1',
  function success() {
    casper.CustomEcho('ID FOUND');
    casper.capture('screenshots/SS2.png');
  },
  function fail() {
    console.log("oops! ID is not Found..!.");
  }
);

  casper.capture('screenshots/I_Am_in_Then_SS3.png');
  casper.CustomEcho('*****_exit_*********');
  casper.exit();

这可能有用,我还没有测试过。