2013-03-03 107 views
0

想这个答案 How to login into a website with CasperJS?后,我没有明显的工作注入功能是一个失败的 现在,Facebook并不具备鄂麦,并通过login_form的直接孩子这样做会影响代码?我想它停在this.test.assert ... 我的代码CasperJS登录Facebook的

var casper = require('casper').create({ 
    pageSettings: { 
     loadImages: false,   // The WebPage instance used by Casper will 
     loadPlugins: false,   // use these settings 
     userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4' 
    } 
}); 
var url = 'https://www.facebook.com/'; 

casper.start(url, function() { 
    console.log("page loaded"); 
    this.test.assertExists('form#login_form', 'form is found'); 
    this.fill('form#login_form', { 
     email: 'email', 
     pass: 'pass' 
    }, true); 
}); 

casper.then(function() { 
    this.evaluateOrDie(function() { 
     return /message sent/.test(document.body.innerText); 
    }, 'sending message failed'); 
}); 

casper.run(function() { 
    this.echo('message sent').exit(); 
}); 

如果没有答案,我得到了我需要PhantomJS工作仅

回答

0

版本问题,看不清楚是什么问题。

0

变化从

call phantomjs "%CASPER_BIN%bootstrap.js" --casper-path="%CASPER_PATH%" --cli %ARGV% 

调用在batchbin/casperjs.bat文件phantomjs到

call phantomjs --ignore-ssl-errors=yes "%CASPER_BIN%bootstrap.js" --casper-path="%CASPER_PATH%" --cli %ARGV% 

这只是强迫ignore-ssl-errors在每次调用phantomjs,这对于我的使用情况是好的。这不是一个修复,只是一个破解。

https://github.com/n1k0/casperjs/issues/49