-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,328 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import LoginPage from "./po/login.page" | ||
import SecurePage from "./po/secure.page" | ||
|
||
describe("My Login application", () => { | ||
it("should login with valid credentials", async () => { | ||
await LoginPage.open() | ||
|
||
await LoginPage.login("tomsmith", "SuperSecretPassword!") | ||
await expect(SecurePage.flashAlert).toBeExisting() | ||
await expect(SecurePage.flashAlert).toHaveTextContaining("You logged into a secure area!") | ||
}) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { ChainablePromiseElement } from "webdriverio" | ||
|
||
import Page from "./page" | ||
|
||
/** | ||
* sub page containing specific selectors and methods for a specific page | ||
*/ | ||
class LoginPage extends Page { | ||
/** | ||
* define selectors using getter methods | ||
*/ | ||
public get inputUsername(): ChainablePromiseElement<Promise<WebdriverIO.Element>> { | ||
return $("#username") | ||
} | ||
|
||
public get inputPassword(): ChainablePromiseElement<Promise<WebdriverIO.Element>> { | ||
return $("#password") | ||
} | ||
|
||
public get btnSubmit(): ChainablePromiseElement<Promise<WebdriverIO.Element>> { | ||
return $('button[type="submit"]') | ||
} | ||
|
||
/** | ||
* a method to encapsule automation code to interact with the page | ||
* e.g. to login using username and password | ||
*/ | ||
public async login(username: string, password: string): Promise<void> { | ||
await this.inputUsername.setValue(username) | ||
await this.inputPassword.setValue(password) | ||
await this.btnSubmit.click() | ||
} | ||
|
||
/** | ||
* overwrite specific options to adapt it to page object | ||
*/ | ||
public open(): Promise<string> { | ||
return super.open("login") | ||
} | ||
} | ||
|
||
export default new LoginPage() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* main page object containing all methods, selectors and functionality | ||
* that is shared across all page objects | ||
*/ | ||
export default class Page { | ||
/** | ||
* Opens a sub page of the page | ||
* @param path path of the sub page (e.g. /path/to/page.html) | ||
*/ | ||
public open(path: string): Promise<string> { | ||
return browser.url(`https://the-internet.herokuapp.com/${path}`) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ChainablePromiseElement } from "webdriverio" | ||
|
||
import Page from "./page" | ||
|
||
/** | ||
* sub page containing specific selectors and methods for a specific page | ||
*/ | ||
class SecurePage extends Page { | ||
/** | ||
* define selectors using getter methods | ||
*/ | ||
public get flashAlert(): ChainablePromiseElement<Promise<WebdriverIO.Element>> { | ||
return $("#flash") | ||
} | ||
} | ||
|
||
export default new SecurePage() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"types": [ | ||
"node", | ||
"webdriverio/async", | ||
"@wdio/mocha-framework", | ||
"expect-webdriverio" | ||
], | ||
"target": "ES5" | ||
} | ||
} |
Oops, something went wrong.