0
ログイン:CasperJSは、私がページにログインを試みるフォーム待ち成功
var casper = require('casper').create();
casper.start('http://sprashivai.ru/', function() {
this.click('#signin_link');
this.capture('foo.jpg', undefined, {
format: 'jpg',
quality: 75
});
this.fillSelectors('form', {
'#signin_username' : '[email protected]*****',
'#signin_pass' : '*****'
}, true);
casper.then(function() {
this.capture('foo_2.jpg', undefined, {
format: 'jpg',
quality: 75
});
});
casper.thenOpen(function() {
this.capture('foo_3.jpg', undefined, {
format: 'jpg',
quality: 75
});
});
casper.then(function() {
this.capture('foo_4.jpg', undefined, {
format: 'jpg',
quality: 75
});
});
this.waitForSelector("#top_nq_badge",
function pass() {
test.pass("Found #top_nq_badge");
},
function fail() {
test.fail("Did not load element #top_nq_badge");
},
20000 // timeout limit in milliseconds
);
});
casper.run();
は私がログインした後、私は要素#top_nq_badgeを見ることができますが、waitForSelectorはない私のために働くことを知っています。 ページにCasperJSを使ってどのようにログインできますか?
私はスクリプトを実行します: $ casperjs secr.js これは何も印刷せず、スクリプトの成功はエラーなしで機能しました。
foo_3.jpgとfoo_4.jpgファイルはスクリプトで作成されていません。 しかし、私のfoo.jpgというおよびfoo_2.jpgスクリーンショット:
[foo_0.jpg](https://drive.google.com/open?id=0B_tqnSHhFPBnREpOeVVjdFc4eWc)| [foo_1.jpg](https://drive.google.com/open?id=0B_tqnSHhFPBnSmI0a2NucEZRZUk)| [foo_2.jpg](https://drive.google.com/open?id=0B_tqnSHhFPBnOVBYSFE1MTBkLVE)| [foo_3.jpg](https://drive.google.com/open?id=0B_tqnSHhFPBnYURFMXlmMnlhMGc)| [foo_4.jpg](https://drive.google.com/open?id=0B_tqnSHhFPBnZGliRFFQc0Viams) –
[ここでUserAgentを選んでください](https://github.com/dillbyrne/random-agent-spoofer/blob/master/ data/json/useragents.json) –
はい、このセレクタの読み込みは非常にゆっくりです。 –