問題:私はアプリケーションにログインするCasperjsスクリプトを作成しています。アプリケーションはgoogle authを使用します。ユーザーがどのようにサインインするかをシミュレートしようとしているので、サイトに行くと、まずユーザーはGoogleのサインインボタンをクリックし、新しいタブでGoogleの資格情報を要求します。私はこれらの作品が動作している...私がついているところは、ユーザーがGoogleの認証フォームを提出し、サインインタブが閉じて元のウィンドウがそれらのクレデンシャルを受け取り、ユーザーをアプリケーションに入れることが期待できるということです。これらのイベントの後にスクリーンショットを撮ると、アプリにアクセスするのではなく、元のログインページに残ります。それは、私はそれが本当にユーザーでログインしていないと思われるので...つかむためにそれを言ったセレクタを見つけることができないので、私は、スクリプトがタイムアウトしますthis.waitForSelector('.dashboard-container',
ラインに到達するとCasperjs Google認証ポップアップ
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
waitTimeout: 5000,
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4'
});
casper.capturePath = function(name) {
return this.capture('./captures/' + name)
}
casper.on('remote.message', function(msg) {
this.echo('remote message caught: ' + msg);
});
casper.on("page.error", function(msg, trace) {
this.echo("Page Error: " + msg, "ERROR");
});
casper.on('popup.created', function() {
this.echo("url popup created : " + this.getCurrentUrl(),"INFO");
});
casper.on('popup.loaded', function() {
this.echo("url popup loaded : " + this.getCurrentUrl(),"INFO");
});
casper
.start('<url>', function() {
this
.then(function() {
this.clickLabel('Sign in with Google', 'button');
})
.waitForPopup(/accounts\.google/)
.withPopup(/accounts\.google/, function(popup) {
this
.fillSelectors('form#gaia_loginform', { '#Email': '<username>' }, false)
.thenClick('input#next')
.wait(500, function() {
this.waitForSelector('#Passwd',
function success() {
this
.echo('success', 'INFO')
.fillSelectors('form#gaia_loginform', { 'input[name=Passwd]': '<password>' }, false)
.capturePath('beforeSubmit.png')
.thenClick('input#signIn')
.wait(500, function() {
this.capturePath('afterSubmit.png');
})
},
function fail() {
this.echo('failure');
})
})
})
})
.then(function() {
this.waitForSelector('.dashboard-container',
function success() {
this
.echo('logged in!', 'INFO')
.capturePath('in.png')
},
function fail() {
this
.capturePath('failed.png')
.echo('failed to login', 'ERROR');
})
})
.run();
:私のコードは、下に掲載されています。 (また、アプリケーションは、重要なことをする反応アプリケーションです)
私はしばらくの間この車に私の車輪を回転されている、任意の洞察力は非常に感謝される!
どのバージョンのphantomJS/CasperJSをお使いですか? –
エラーが記録されましたか? – Vaviloff
phantomjs:2.1.1、casperjs:1.1.3 – jallen