Last active
August 29, 2015 14:02
-
-
Save NathanGloyn/705a0eaf5a4585b02daa to your computer and use it in GitHub Desktop.
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
function LoginFlow() { | |
this.loginPage = new LoginPage(driver); // another question is how to provide the driver, global or parameter? | |
function login(username, password){ | |
loginPage.userName.text = username; | |
loginPage.password.text = password; | |
loginPage.loginButton.click(); | |
dalek.waitFor(window.document.title == 'Home'); // ideally wouldn't want to have to use dalek, driver would be better | |
} | |
} |
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
function LoginPage(driver) { | |
this.userName = driver.getElement('#userName'); | |
this.password = driver.getElement("#password"); | |
this.loginButton = driver.getElement("#loginButton"); | |
}; |
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 loginPage = require('./loginPage.js'); | |
var loginFlow = require('./loginFlow.js'); | |
module.exports = { | |
'Login displays': function (test) { | |
test | |
.open('http://www.mytest.site/login') | |
.chain() | |
.assert. | |
.assert.exists(loginPage.userName); | |
.assert.exists(loginPage.password); | |
.assert.exists(loginPage.loginButton); | |
.done(); | |
} | |
'Able to login': function (test) { | |
loginFlow.login(); | |
test.assertTitle('My Account') | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have the absolute minimum experience with require so not sure how best to provide the driver to the login page.