Skip to content

Instantly share code, notes, and snippets.

@fwon
Created September 15, 2014 05:43
Show Gist options
  • Save fwon/3a018d31790b2faccf8f to your computer and use it in GitHub Desktop.
Save fwon/3a018d31790b2faccf8f to your computer and use it in GitHub Desktop.
casper filling and login test
casper.test.begin('test 163 mail login', 2, function(test) {
casper.start('http://mail.163.com/', function() {
this.capture('step1.png');
test.assertExists('#loginBtn');
this.fill('form', {
'username': 'xxx',
'password': 'xxx'
}, true);
this.click('#loginBtn');
this.capture('step2.png');
var timeout = 3000;
this.waitFor(function(){
return this.getTitle().indexOf('网易邮箱') != -1;
}, function() {
this.echo('登录成功');
this.capture('step3.png');
}, function() {
this.capture('timeout.png');
this.die('超时');
}, timeout);
}).run(function() {
test.done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment