diff --git a/.eslintrc.js b/.eslintrc.js index 65504b7..c8e992f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -31,7 +31,6 @@ module.exports = { "@typescript-eslint/semi": [ "error" ], - "@typescript-eslint/explicit-function-return-type": ["error"] }, extends: [ "plugin:wdio/recommended", diff --git a/config/wdio-android.conf.ts b/config/wdio-android.conf.ts index 53dccf6..6ede799 100644 --- a/config/wdio-android.conf.ts +++ b/config/wdio-android.conf.ts @@ -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", diff --git a/src/AccountType.ts b/src/AccountType.ts new file mode 100644 index 0000000..a7ed3fd --- /dev/null +++ b/src/AccountType.ts @@ -0,0 +1,6 @@ +export enum AccountType { + Standard = "standard", + LocKed = "locked", + Problem = "problem", + Performance = "performance" +} \ No newline at end of file diff --git a/src/Credentials.ts b/src/Credentials.ts new file mode 100644 index 0000000..664bdab --- /dev/null +++ b/src/Credentials.ts @@ -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]; + } +} \ No newline at end of file diff --git a/src/interfaces/ICredentials.ts b/src/interfaces/ICredentials.ts new file mode 100644 index 0000000..90ecf5c --- /dev/null +++ b/src/interfaces/ICredentials.ts @@ -0,0 +1,4 @@ +export default interface ICredentials { + userName: string, + password: string +} \ No newline at end of file diff --git a/src/pages/LoginPage.ts b/src/pages/LoginPage.ts new file mode 100644 index 0000000..3127f64 --- /dev/null +++ b/src/pages/LoginPage.ts @@ -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 { + const {userName, password} = credentials; + await this.enterEmail(userName); + await this.enterPassword(password); + await this.clickOnLogInButton(); + } +} + +export const LoginPage = new Login() \ No newline at end of file diff --git a/test/specs/android/logIn.ts b/test/specs/android/logIn.ts index ad333fa..5691353 100644 --- a/test/specs/android/logIn.ts +++ b/test/specs/android/logIn.ts @@ -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"); }); }); \ No newline at end of file