0
我試圖使用casper登錄到http://insider.espn.go.com/insider/pickcenter/。 現在的問題是,當你點擊登錄按鈕,一個AngularJS生成的文件 - 用戶名和密碼出現。 我已經把WaitForSelector等待這個彈出窗口。但它總是退出說「超時過期」使用Casper以Javascript生成的內容登錄頁面
這是我的腳本。請幫忙。
var links = [];
var casper = require("casper").create();
function getLinks() {
var links = document.querySelectorAll('a');
return Array.prototype.map.call(links, function(e) {
return e.getAttribute('href');
});
}
casper.on('page.loaded', function() {
this.echo('page title is ' + this.getTitle());
});
casper.start('http://insider.espn.go.com/insider/pickcenter/', function() {
// search for 'casperjs' from google form
this.emit('page.loaded');
casper.capture('test1.png');
this.click('#ins_signin');
});
casper.wait(5000,function(){
casper.capture('test2.png')
});
casper.wait(5000,function(){
casper.capture('test3.png')
});
casper.waitForSelector(".ng-scope", function() {
this.echo('Login Modal Active!');
casper.capture('test4.png');
//this.capture('screenshotofmodal.png', { top: 0, left:0, width:1000, height: 4000});
});
casper.then(function() {
this.fill('input[id="username"]', { q: 'removed' }, true);
this.fill('input[id="passwordfield"]', { q: 'removed' }, true);
});
casper.then(function() {
this.click('#submitBtn');
});
casper.then(function() {
// aggregate results for the 'phantomjs' search
links = links.concat(this.evaluate(getLinks));
});
casper.run(function() {
// echo results in some pretty fashion
this.echo(links.length + ' links found:');
this.echo(' - ' + links.join('\n - ')).exit();
});
我不能在您的文章,所以我不得不回答甚至儘管我對你問題的時候了,所以我會在這裏問他們,希望你看到它的評論。什麼test2.png呈現給你,與您的初始代碼張貼? –