CasperJS / PhantomJS在加载页面时窒息

时间:2016-01-10 17:51:29

标签: javascript phantomjs casperjs

我用phantomjs运行以下脚本:

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

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

现在我收到以下错误:

//return to sql last_update (select db ...)

$current_Data = date ('Y-m-d');
$current_Data_time = strtotime ($current_Data); //convert data to time
$last_update_p3 = strtotime ("+3day", strtotime($last_update));
$last_update_p3 = strtotime ($last_update_p3);//convert data to time

if($current_Data_time <=$last_update_p3)
{
 $sql = $con->query("UPDATE users SET HWID = '{$UpdateHWID}' , last_update='{$current_Data}'  where UserID = $User");
//update last data with current date 
}
else
{
//It has not gone three days 
}

使用slimerjs作为引擎加载页面很好,但是当使用slimerjs时,登录表单不会被填充,因为窗口不在焦点上。 我相信这是一个问题,其中casper使用旧版本的WebKit并在加载页面时窒息。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:6)

解决问题太晚了但如果有人在PhantomJS中找到startsWith的问题搜索问题(如我所做的那样)可能对将来参考有用:在ECMAScript 6上添加了startsWith方法规范,PhantomJS不支持。

一个好的polyfill是mathiasbynens/String.prototype.startsWith