Skip to content

Instantly share code, notes, and snippets.

@NathanGloyn
Last active August 29, 2015 14:02
Show Gist options
  • Save NathanGloyn/705a0eaf5a4585b02daa to your computer and use it in GitHub Desktop.
Save NathanGloyn/705a0eaf5a4585b02daa to your computer and use it in GitHub Desktop.
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
}
}
function LoginPage(driver) {
this.userName = driver.getElement('#userName');
this.password = driver.getElement("#password");
this.loginButton = driver.getElement("#loginButton");
};
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')
}
};
@NathanGloyn
Copy link
Author

I have the absolute minimum experience with require so not sure how best to provide the driver to the login page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment