Skip to content

Instantly share code, notes, and snippets.

@fritz-gerneth
Last active December 15, 2015 13:59
Show Gist options
  • Save fritz-gerneth/5271560 to your computer and use it in GitHub Desktop.
Save fritz-gerneth/5271560 to your computer and use it in GitHub Desktop.
Meteor login with password extension for Selenium Webdriver
var driver = new webDriver.Builder()
.withCapabilities({
browserName: 'firefox'
})
.build();
driver.manage()
.timeouts()
.setScriptTimeout(3000);
driver.manage()
.timeouts()
.implicitlyWait(1000);
driver.loginWithPassword = function (email, password) {
var defer = webDriver.promise.defer();
driver.executeAsyncScript(
function (e, p) {
var callback = arguments[arguments.length - 1];
Meteor.loginWithPassword(e, p, callback);
},
email,
password
)
.then(function (res) {
res === null
? defer.resolve()
: defer.reject(res);
});
return defer.promise;
};
it('Can be viewed when logged in', function (done) {
driver.loginWithPassword('[email protected]', 'test12');
driver.goToPage('account');
driver.getCurrentUrl().then(function (realURL) {
realURL.should.equal(driver.getUrlOfPage('account'));
}).then(done);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment