Last active
November 25, 2015 17:38
-
-
Save scottrippey/65735c421bbf74108f3e to your computer and use it in GitHub Desktop.
Here are theoretical examples of how "page objects" would work. Looking for an expressive syntax that maximizes the test-writing experience.
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
describe("page objects", function() { | |
var loginPage = pageObjects.loginPage; | |
it("here's what we've got now; page commands and element commands", function() { | |
return browser | |
.loginPage_email_setValue("a@b.c") | |
.loginPage_password_setValue("pass") | |
.loginPage_loginButton_click() | |
.loginPage_errorMessage_getText().should.become("Oops, some error") | |
; | |
}); | |
it("page is a chain of promises", function() { | |
return loginPage | |
.email.setValue("a@b.c") | |
.password.setValue("pass") | |
.loginButton.click() | |
.errorMessage.getText().should.become("Oops, some error") | |
; | |
}); | |
it("page is a utility", function() { | |
return browser | |
.url(loginPage.url) | |
.then(loginPage.email.setValue("a@b.c")) | |
.then(loginPage.password.setValue("pass")) | |
.then(loginPage.loginButton.click()) | |
.then(loginPage.errorMessage.getText()).should.become("Oops, some error") | |
; | |
}); | |
it("uses yield to do the magic", function() { | |
return Promise.coroutine(function* () { | |
yield loginPage.email.setValue("a@b.c"); | |
yield loginPage.password.setValue("pass"); | |
yield loginPage.loginButton.click(); | |
var errorMessage = yield loginPage.errorMessage.getText(); | |
errorMessage.should.equal("Oops, some error"); | |
}); | |
}); | |
it("uses some other magic", function() { | |
return browser.steps( | |
loginPage.email.setValue("a@b.c"), | |
loginPage.password.setValue("pass"), | |
loginPage.loginButton.click(), | |
loginPage.errorMessage.getText().should.become("Oops, some error"), | |
); | |
}); | |
it("uses statements", function() { | |
var loginPage = new LoginPage(); | |
loginPage.email.setValue("a@b.c"); | |
loginPage.password.setValue("pass"); | |
loginPage.loginButton.click(); | |
loginPage.errorMessage.shouldHaveText("Oops, some error"); | |
return loginPage; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment