2013-07-08 33 views
1

這是我使用的登錄到Quora的代碼:爲什麼我的CasperJS代碼不能登錄Quora?

var casper = require('casper').create({ 
    verbose: true, 
    logLevel: 'debug', 
    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' 
    } 
}); 

casper.start('http://www.quora.com', function() 
    { 
     this.echo("page loaded"); 
     this.test.assertExists('form.inline_login_form', 'form is found'); 
     this.fill('form.inline_login_form',{email:'XXXXX',password:'XXXXX'},true); 

    } 
); 


casper.then(function(){ 
    this.echo("Page Title " + document.title); 
}); 

casper.run(); 

這是我看到的輸出:我期待它來登錄,並告訴我標題

[info] [phantom] Starting... 
[info] [phantom] Running suite: 3 steps 
[debug] [phantom] opening url: http://www.quora.com/, HTTP GET 
[debug] [phantom] Navigation requested: url=http://www.quora.com/, type=Other, lock=true, isMainFrame=true 
[debug] [phantom] Navigation requested: url=https://www.quora.com/, type=Other, lock=true, isMainFrame=true 
[debug] [phantom] url changed to "https://www.quora.com/" 
[debug] [phantom] Successfully injected Casper client-side utilities 
[info] [phantom] Step 2/3 https://www.quora.com/ (HTTP 302) 
page loaded 
PASS form is found 
[info] [remote] attempting to fetch form element from selector: 'form.inline_login_form' 
[debug] [remote] Set "email" field value to XXXXXXX 
[debug] [remote] Set "password" field value to ******** 
[info] [remote] submitting form to unknown, HTTP POST 
[info] [phantom] Step 2/3: done in 2517ms. 
[debug] [phantom] Navigation requested: url=about:blank, type=Other, lock=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=about:blank, type=Other, lock=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=https://www.quora.com/, type=FormSubmitted, lock=true, isMainFrame=true 
[debug] [phantom] Navigation requested: url=https://s-static.ak.facebook.com/connect/xd_arbiter.php?version=25#channel=f2c1b2e7dc&origin=https://www.quora.com&channel_path=/?fb_xd_fragment#xd_sig=f3e9a78ef8&, type=Other, lock=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=https://www.facebook.com/plugins/facepile.php?size=small&max_rows=1&width=400&color_scheme=dark&app_id=136609459636&locale=en_US&sdk=joey&channel=https://s-static.ak.facebook.com/connect/xd_arbiter.php?version=25#cb=f2850df0f8&origin=https%3A%2F%2Fwww.quora.com%2Ff2c1b2e7dc&domain=www.quora.com&relation=parent.parent, type=Other, lock=true, isMainFrame=false 
[info] [remote] Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL https://www.facebook.com/plugins/facepile.php?size=small&max_rows=1&width=400&color_scheme=dark&app_id=136609459636&locale=en_US&sdk=joey&channel=https%3A%2F%2Fs-static.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D25%23cb%3Df2850df0f8%26origin%3Dhttps%253A%252F%252Fwww.quora.com%252Ff2c1b2e7dc%26domain%3Dwww.quora.com%26relation%3Dparent.parent. Domains, protocols and ports must match. 

[debug] [phantom] url changed to "https://www.quora.com/" 
[debug] [phantom] Successfully injected Casper client-side utilities 
[info] [phantom] Step 3/3 https://www.quora.com/ (HTTP 302) 
Page Title 
[info] [phantom] Step 3/3: done in 5876ms. 
[info] [phantom] Done 3 steps in 5975ms 

。像'Home-Quora ..' 爲什麼沒有這種情況發生?

回答

0

您是否試圖用您的Facebook密碼登錄?如果是這樣,由於彈出窗口被阻止,通過Facebook登錄會出現問題。

相關問題