我正在使用 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 并在加载页面时卡住的问题。我该如何解决这个问题?
解决问题为时已晚,但如果有人发现搜索问题的问题,可能对将来的参考有用startsWith
在 PhantomJS 中(正如我所做的那样):startsWith https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/startsWithECMAScript 6 规范中添加了该方法,PhantomJS 不支持该方法。
一个很好的填充是mathiasbynens/String.prototype.startsWith https://github.com/mathiasbynens/String.prototype.startsWith
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)