Casperjs/phantomjs加载页面[英] CasperJS/PhantomJS chokes on loading a page

问题描述

我正在使用phantomjs运行以下脚本:

var casper = require('casper').create();
var url = 'https://itunesconnect.apple.com/itc/static/login?view=1&path=%2FWebObjects%2FiTunesConnect.woa%3F'

casper.on("page.error", function(msg, trace) {
  this.echo("Error:    " + msg, "ERROR");
  this.echo("file:     " + trace[0].file, "WARNING");
  this.echo("line:     " + trace[0].line, "WARNING");
  this.echo("function: " + trace[0]["function"], "WARNING");
  errors.push(msg);
});



casper.start(url, function(){
    casper.wait(7000, function(){
        // casper.echo(casper.getHTML());
    })
})

casper.run(function() {
  if (errors.length > 0) {
    this.echo(errors.length + ' Javascript errors found', "WARNING");
  } else {
    this.echo(errors.length + ' Javascript errors found', "INFO");
  }
  casper.exit();
});

直到几天前,我可以访问加载包含2个表单字段的iframe的页面,以允许用户登录.

现在我收到以下错误:

Error:    Error: undefined is not a constructor (evaluating '$stateParams.path.startsWith('/')')

    at setupDSiFrame (https://itunesconnect.apple.com/itc/static-resources/controllers/login_cntrl.js?cache=111920151100:99:46)

    at https://itunesconnect.apple.com/itc/static-resources/controllers/login_cntrl.js?cache=111920151100:19:37

    at $digest (https://itunesconnect.apple.com/itc/js/compiled/lib/vendor.js?cache=111920151100:13:11750)

    at $apply (https://itunesconnect.apple.com/itc/js/compiled/lib/vendor.js?cache=111920151100:13:13237)

    at f (https://itunesconnect.apple.com/itc/js/compiled/lib/vendor.js?cache=111920151100:12:56414)

    at r (https://itunesconnect.apple.com/itc/js/compiled/lib/vendor.js?cache=111920151100:12:65848)

    at onreadystatechange (https://itunesconnect.apple.com/itc/js/compiled/lib/vendor.js?cache=111920151100:12:66409)

file:     https://itunesconnect.apple.com/itc/js/compiled/lib/vendor.js?cache=111920151100

line:     12

使用Slimerjs作为引擎,页面可以正加载,但是当使用Slimerjs时,登录表单不会填写,因为窗口不在焦点上. 我相信这是Casper使用旧版本的WebKit并cho住页面上的问题.我该如何解决?

推荐答案

为时已晚,无法解决该问题,但如果有人在phantomjs中发现startsWith搜索问题的问题(就像我所做的那样): startsWith 在ecmascript 6规格中添加了方法,phantomjs不支持

mathiasbynens/string.prototype.startspe.startswith

本文地址:https://www.itbaoku.cn/post/1740059.html