Skip to content

Instantly share code, notes, and snippets.

@SomeKittens

SomeKittens/login.js

Created Oct 25, 2013
Embed
What would you like to do?
Zombie.js login to StackOverflow
var Browser = require('zombie');
var url = 'http://stackoverflow.com/users/login?returnurl=http%3a%2f%2fchat.stackoverflow.com%2frooms%2f17%2fjavascript';
//url = 'http://chat.stackoverflow.com/rooms/17/javascript';
browser = new Browser({maxWait: 500});
//console.log(browser.cookies);
//browser.cookies(url).set('session', '123');
browser.visit(url, function(e) {
if (e) return console.error(e);
//console.log(browser);
browser.wait(function(window) {
return window.document.querySelector('#openid_highlight');
}, function() {
console.log(browser.document.querySelector('#openid_btns').firstChild.href);
console.log(browser.document.querySelector('#openid_highlight'));
browser.evaluate('openid.signin("stack_exchange")');
browser.wait(function(window) {
return window.document.querySelectorAll('iframe').length === 2;
}, function() {
var login = browser.document.querySelectorAll('iframe')[0].src;
console.log(browser.document.querySelectorAll('iframe')[0].id);
console.log(browser.document.querySelectorAll('iframe').length);
console.log('fdlas;');
browser.visit(login, function() {
console.log(browser.document.querySelector('#email').placeholder);
browser
.fill('#email', 'rkoutnik@gmail.com')
.fill('#password', 'hunter2')
.pressButton('input[type="submit"]', function() {
console.log(browser.window.location.href);
console.log(browser.document.querySelector('.profile-link').innerHTML);
// console.log(browser.document.querySelector('.hlinks').innerHTML);
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment