1
casper.jsを使用してページにログインしてページを表示する方法はありますか? 私はそれを実際のページにしたいと思うスクリーンショットを撮ることができます。Casper.jsウェブページとディスプレイを取得する
イムは確かにその非常に間違っているが、私は、これまで持っているもの。ここ:
var casper = require('casper').create({
viewportSize: {
width: 1365,
height: 768
},
// engine: 'slimmerjs',
verbose: true,
logLevel: "debug",
pageSettings: {
loadImages: false,//The script is much faster when this field is set to false
loadPlugins: false,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36'
}
});
//First step is to open
casper.start().thenOpen("http://mysite/login", function() {
console.log("mysite website opened");
});
//Now we have to populate username and password, and submit the form
casper.then(function(){
console.log("Login using username and password");
this.evaluate(function(){
document.getElementById("user_email").value="me";
document.getElementById("user_password").value="password";
document.getElementById('new_user').submit();
});
});
casper.thenOpen('http://mysite/report/70?dashboard_id=2', function(){
console.log("Make a screenshot of morning info and save it as pic.png");
this.wait(10000, function(){
this.captureSelector('pic.png','.highcharts- container');
});
});
casper.start("http://mysite/report/70?dashboard_id=2", function() {
this.page.switchToChildFrame(0);
this.page.switchToParentFrame();
});
casper.run(function() {
this.exit();
});
casper.run();
「私はそれを実際のページにしますか?」という意味を定義できますか?あなたはソースコードをダウンロードしたいですか?または、他の何か? –
@ user2720970次のURLを開く前に 'submit()'が終了するのを待ちます。あなたは 'http:// mysite/report/70?dashboard_id = 2'を待っていましたが、提出が完了していない – Twometer