-
-
Save fritz-gerneth/5271560 to your computer and use it in GitHub Desktop.
Meteor login with password extension for Selenium Webdriver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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