-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test to log in with stantard_user
- Loading branch information
1 parent
9007bc5
commit 5cb9c7b
Showing
7 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
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
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,6 @@ | ||
export enum AccountType { | ||
Standard = "standard", | ||
LocKed = "locked", | ||
Problem = "problem", | ||
Performance = "performance" | ||
} |
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,27 @@ | ||
import {AccountType} from "./AccountType"; | ||
import ICredentials from "./interfaces/ICredentials"; | ||
|
||
export default class Credentials { | ||
private static readonly accountInfo = { | ||
standard: { | ||
userName: "standard_user", | ||
password: "secret_sauce" | ||
}, | ||
locked: { | ||
userName: "locked_out_user", | ||
password: "secret_sauce" | ||
}, | ||
problem: { | ||
userName: "problem_user", | ||
password: "secret_sauce" | ||
}, | ||
performance: { | ||
userName: "performance_glitch_user", | ||
password: "secret_sauce" | ||
}, | ||
}; | ||
|
||
public static getUserCredentials(accountType: AccountType): ICredentials { | ||
return this.accountInfo[accountType]; | ||
} | ||
} |
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,4 @@ | ||
export default interface ICredentials { | ||
userName: string, | ||
password: string | ||
} |
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,37 @@ | ||
import ICredentials from "../interfaces/ICredentials"; | ||
|
||
class Login { | ||
|
||
private get inputEmail() { | ||
return $("~test-Username"); | ||
} | ||
|
||
private get inputPassword() { | ||
return $("~test-Password"); | ||
} | ||
|
||
private get logInButton() { | ||
return $("//android.view.ViewGroup[@content-desc=\"test-LOGIN\"]/android.widget.TextView"); | ||
} | ||
|
||
private async enterEmail(userName: string) { | ||
await this.inputEmail.setValue(userName); | ||
} | ||
|
||
private async enterPassword(userPassword: string) { | ||
await this.inputPassword.setValue(userPassword); | ||
} | ||
|
||
private async clickOnLogInButton() { | ||
await this.logInButton.click(); | ||
} | ||
|
||
public async logInWithCredentials(credentials: ICredentials): Promise<void> { | ||
const {userName, password} = credentials; | ||
await this.enterEmail(userName); | ||
await this.enterPassword(password); | ||
await this.clickOnLogInButton(); | ||
} | ||
} | ||
|
||
export const LoginPage = new Login() |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import Credentials from "../../../src/Credentials"; | ||
import {AccountType} from "../../../src/AccountType"; | ||
import {LoginPage} from "../../../src/pages/LoginPage"; | ||
|
||
describe("Log in tests", () => { | ||
// beforeEach(async () => { | ||
// await $("~open menu").click(); | ||
// await $('//*[@text="Log In"]').click(); | ||
// }); | ||
|
||
it("", async () => { | ||
await $("~test-Username") | ||
it("Log in as \"standard_user\"", async () => { | ||
await LoginPage.logInWithCredentials(Credentials.getUserCredentials(AccountType.Standard)); | ||
const headerText = await $("//android.view.ViewGroup[@content-desc=\"test-Cart drop zone\"]/android.view.ViewGroup/android.widget.TextView"); | ||
await expect( await headerText.getText()).toEqual("PRODUCTS"); | ||
}); | ||
}); |