Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Logs in and dumps cookies
var Browser = require('zombie');
var url = 'http://stackoverflow.com/users/login?returnurl=http%3a%2f%2fchat.stackoverflow.com%2frooms%2f17%2fjavascript';
browser = new Browser();
browser.visit(url, function(e) {
browser.wait(function(window) {
return window.document.querySelector('#openid_highlight');
}, function() {
console.log('First login stage');
browser.evaluate('openid.signin("stack_exchange")');
browser.wait(function(window) {
return window.document.querySelectorAll('iframe').length === 2;
}, function() {
console.log('Getting iframe src');
var login = browser.document.querySelectorAll('iframe')[0].src;
browser.visit(login, function() {
console.log('Actually logging in');
browser
.fill('#email', 'rkoutnik@gmail.com')
.fill('#password', 'hunter2')
.pressButton('input[type="submit"]', function() {
console.log('Now at StackOverflow root');
console.log(browser.cookies);
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment