【问题标题】:Why does CasperJS capture is not working?为什么 CasperJS 捕获不起作用?
【发布时间】:2017-10-06 04:04:11
【问题描述】:

希望你一切都好,

目的:页面加载完毕后截图

已尝试:已尝试等待一些 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();
});

提前致谢!

【问题讨论】:

  • 你可以在运行脚本后发布你在控制台中打印的内容吗?
  • 如代码所示(casper.echo & casper.CustomEcho(UDF))
  • 你得到screenshots/I_Am_in_Then_SS3.pngID FOUND
  • 是的,但该语句之后的屏幕截图完全空白(带有白色背景)!
  • 网址是HTTPS吗?如果是这样,请在 cmd 行中使用 --ignore-ssl-erros=true

标签: javascript casperjs


【解决方案1】:

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();

这可能有效,我没有测试过。

【讨论】:

  • 对不起兄弟。 casper.waitFor(function StepOne() { return true; 这里有什么用?
  • 但它不起作用
猜你喜欢
  • 1970-01-01
  • 2021-10-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-10
  • 2011-02-11
相关资源
最近更新 更多