本文介绍了为什么CasperJS不能展示网站'outlook.com'的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有捕获网页所有内容的问题。在我使用常规浏览器登录outlook.com后,它应该在右侧显示收件箱消息:
I have problem of capturing everything of a web page. After I log in to outlook.com using regular browser, it should show the inbox message in the right side:
然而,当我使用CasperJS时,它只是空白。有谁有想法吗?
However, when I use CasperJS, it is just blank. Does anyone have any idea?
我在脚本中包含了一个临时登录ID,你可以测试一下,谢谢。
I have include a temporary login id in the script, you can test it if you can, thanks.
这是脚本:
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?
Should I maybe add any path/plugin to support this CasperJS?
推荐答案
尝试以下代码。您需要提供/提供足够的时间来打开网页
Try the below code. You need to give/provide enough time to open web page
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();
这篇关于为什么CasperJS不能展示网站'outlook.com'的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!