Skip to content

Commit

Permalink
Added test to log in with stantard_user
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimNastoyashchy committed Nov 30, 2022
1 parent 9007bc5 commit 5cb9c7b
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 7 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module.exports = {
"@typescript-eslint/semi": [
"error"
],
"@typescript-eslint/explicit-function-return-type": ["error"]
},
extends: [
"plugin:wdio/recommended",
Expand Down
1 change: 1 addition & 0 deletions config/wdio-android.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exports.config = {
{
platformName: "Android",
maxInstances: 1,
"appium:avd" : "Pixel_3_API_29",
"appium:deviceName": "Pixel_3_10.0",
"appium:platformVersion": "10.0",
"appium:orientation": "PORTRAIT",
Expand Down
6 changes: 6 additions & 0 deletions src/AccountType.ts
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"
}
27 changes: 27 additions & 0 deletions src/Credentials.ts
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];
}
}
4 changes: 4 additions & 0 deletions src/interfaces/ICredentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default interface ICredentials {
userName: string,
password: string
}
37 changes: 37 additions & 0 deletions src/pages/LoginPage.ts
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()
14 changes: 8 additions & 6 deletions test/specs/android/logIn.ts
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");
});
});

0 comments on commit 5cb9c7b

Please sign in to comment.