【问题标题】:CasperJS not work on Centos Server but work on Windows 10 [duplicate]CasperJS 不适用于 Centos 服务器,但适用于 Windows 10 [重复]
【发布时间】:2017-10-16 03:45:48
【问题描述】:

我在桌面上编写并在 Windows 10 下运行的这段代码一切正常。当我转移到 Centos 服务器时,我开始遇到错误。请帮帮我

CasperError: Cannot get informations from input[name="email"]: element not found.
  /home/casper/casperjs/phantomjs:/platform/casper.js:1158 in getElementInfo
  /home/casper/casperjs/phantomjs:/platform/casper.js:1721 in sendKeys
  /home/casper/casperjs/phantomjs:/code/cars.js:9
  /home/casper/casperjs/phantomjs:/platform/casper.js:1685 in runStep
  /home/casper/casperjs/phantomjs:/platform/casper.js:414 in checkStep

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

casper
    .start('https://example.com', function() {
    this.echo(this.getTitle());
    this.click("span.btn.btn-green");
    }).wait(5000).then(function () {
	    this.capture('sdsdsd.png');
        this.sendKeys('input[name="email"]', 'name');
        this.sendKeys('input[name="password"]', 'pass');
        this.click("button.btn.btn-h40.btn-green.btn-fw.btn-submit");
        console.log("Auth");

    })
casper.run();

【问题讨论】:

  • 截屏是否有有效响应?
  • @Cut-n-paster 感谢您的回答。我发现了问题,是 ssl 握手错误。

标签: javascript centos phantomjs casperjs


【解决方案1】:

使用 phantomjs 选项 --ignore-ssl-errors=true 绕过 SSL 认证验证。欲了解更多信息https://casperjs.readthedocs.io/en/latest/cli.html#casperjs-native-options

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-24
    • 2020-05-24
    • 2020-09-03
    • 2012-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多