2016-02-29 79 views
1

我有捕獲網頁的一切問題。我使用普通瀏覽器登錄到outlook.com後,應在右側顯示收件箱消息:爲什麼CasperJS不能顯示網站'outlook.com'的一部分?

Click here for comparison picture

然而,當我使用CasperJS,它僅僅是空白。有人有什麼主意嗎?

我在腳本中包含一個臨時登錄ID,如果可以的話,您可以測試它,謝謝。

下面是腳本:

var casper = require('casper').create({ 
    verbose: true, 
    logLevel: "info", 
    viewportSize: {width: 1280,height: 720}, 
    pageSettings: {userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"} 
}); 

casper.start('http://www.hotmail.com').then(function() { 
    console.log('got here'); 
}); 

casper.wait(500, function() { 
    console.log('wait'); 
}); 

casper.then(function(){ 
    this.sendKeys("[name='loginfmt']", '[email protected]'); 
    this.sendKeys("[name='passwd']", '12345678peterwhite'); 
    this.click("[type='submit']"); 
    console.log('entering log in information'); 
    }); 

casper.wait(5000, function() { 
    console.log('wait'); 
}); 

casper.then(function(){ 
    console.log('printscreen'); 
    casper.capture('there_is_nothing_by_the_right_side.png') 
}); 

casper.run(); 

我也試着像

casperjs --ssl-protocol=any outlook.js 

如果我也許添加任何路徑/插件,以支持該CasperJS?

+0

,我使用casperjs版本使用phantomjs版本1.9.8 –

+0

你的腳本看起來不錯1.1.0-BETA4。請註冊到'resource.error','page.error','remote.message'和'casper.page.onResourceTimeout'事件([Example](https://gist.github.com/artjomb/4cf43d16ce50d8674fdf#file -2_caspererrors-JS))。也許有錯誤。 –

+0

爲什麼當你已經詢問[這裏]時,你反覆詢問同樣的問題(http://stackoverflow.com/questions/35670589/why-casperjs-can-only-load-half-page-of-outlook-com-images -included) –

回答

2

嘗試下面的代碼。你需要給/提供足夠的時間來打開網頁

var casper = require('casper').create({ 
// verbose: true, 
// logLevel: "info", 
viewportSize: {width: 1280, height: 720}, 
pageSettings: {userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"} 
}); 

casper.start('http://www.hotmail.com').then(function() { 
    console.log('got here'); 
}); 

casper.wait(1000, function() { 
    console.log('wait'); 
}); 

casper.then(function() { 
    this.sendKeys("[name='loginfmt']", '[email protected]'); 
    this.sendKeys("[name='passwd']", '12345678peterwhite'); 
    this.click("[type='submit']"); 
    console.log('entering log in information'); 
}); 

casper.wait(20000, function() { 
    this.waitForSelector('#O365_MainLink_Settings', function() { 
     this.test.assertExists('#O365_Lync_ButtonID', 'Lync icon is visble, hence confirmed that page opened completely'); 
    }); 
}); 

casper.waitForSelector(('._rp_52 > div:nth-child(4)'), function() { 
    if (this.visible("button._rp_o1:nth-child(2)")) { 
     console.log("Here we go, Right side is visible"); 
     casper.capture('there is something.png'); 
    } 
    else { 
     console.log("Nope") 
    } 

}); 

casper.run(); 
+0

嗨prateek,感謝您的幫助,我真的很感激!但是,我仍然無法顯示正確的一面。這裏是我嘗試: –

+0

嗨prateek,感謝您的幫助,我真的很感激!但是,我仍然無法顯示正確的一面。我在「this.test.assertExists」之後放置了一個「控制檯日誌」,但那個控制檯日誌只是沒有顯示....而終端的最後一個回覆是「輸入登錄信息」....另外,如果我刪除「this.waitForSelector&this.test.assertExist」...並在等待20000後直接運行casper.waitForSelector,則終端的回覆超時... –

+0

。我現在關注的是版本我的casperjs ...這是因爲我嘗試了phantomjs 1.9.8,右側是不可見的....但它是可見的,如果我使用phantomjs 2.1.1(但我不知道爲什麼幻影是經過多次嘗試墜毀這讓我非常失望!!)..............你使用哪種版本的casperjs?我在casperjs1.1.0-beta4上。謝謝 –

相關問題