Last active
October 20, 2018 17:30
-
-
Save rickschubert/95e54378aa0bb7f64149be66317d8914 to your computer and use it in GitHub Desktop.
Page Object Await Pattern
This file contains hidden or 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
// Login.page.js | |
import Dashboard from "./pages/Dashboard.page.js" | |
class LoginPage { | |
constructor() { | |
this.awaitFullLoad() | |
} | |
get username() { return '#username' } | |
get password() { return '#password' } | |
get submit() { return '#login' } | |
awaitFullLoad() { | |
browser.waitForVisible(this.username) | |
browser.waitForVisible(this.submit) | |
} | |
login() { | |
browser.setValue(this.username, "R2D2") | |
browser.setValue(this.password, "c3po") | |
browser.click(this.submit) | |
return new Dashboard() | |
} | |
} | |
export default LoginPage | |
// Inside test file | |
import LoginPage from "./pages/Login.page.js" | |
const loginPage = new LoginPage() | |
loginPage.login() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment