-
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.
- Loading branch information
1 parent
f81180c
commit 944563e
Showing
14 changed files
with
220 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { RectReturn } from "@wdio/protocols/build/types"; | ||
|
||
interface ICoordinates { | ||
x: number; | ||
y: number; | ||
} | ||
|
||
const SWIPE_COORDINATES = { | ||
downPoint: { | ||
from: { x: 50, y: 85 }, | ||
to: { x: 50, y: 15 }, | ||
}, | ||
upPoint: { | ||
from: { x: 50, y: 15 }, | ||
to: { x: 50, y: 85 }, | ||
}, | ||
rightPoint: { | ||
from: { x: 95, y: 50 }, | ||
to: { x: 5, y: 50 }, | ||
}, | ||
leftPoint: { | ||
from: { x: 5, y: 50 }, | ||
to: { x: 95, y: 50 }, | ||
}, | ||
}; | ||
|
||
export default class Swipe { | ||
|
||
public static async up() { | ||
await this.swipeOn(SWIPE_COORDINATES.upPoint.from, SWIPE_COORDINATES.upPoint.to); | ||
} | ||
|
||
public static async down() { | ||
await this.swipeOn(SWIPE_COORDINATES.downPoint.from, SWIPE_COORDINATES.downPoint.to); | ||
} | ||
|
||
public static async right() { | ||
await this.swipeOn(SWIPE_COORDINATES.rightPoint.from, SWIPE_COORDINATES.rightPoint.to); | ||
} | ||
|
||
public static async left() { | ||
await this.swipeOn(SWIPE_COORDINATES.leftPoint.from, SWIPE_COORDINATES.leftPoint.to,); | ||
} | ||
|
||
private static async swipeOn(from: ICoordinates, to: ICoordinates) { | ||
const SCREEN_SIZE = await driver.getWindowRect(); | ||
const moveFromScreenCoordinates = this.getDeviceScreenCoordinates(SCREEN_SIZE, from); | ||
const moveToScreenCoordinates = this.getDeviceScreenCoordinates(SCREEN_SIZE, to); | ||
|
||
await this.swipe(moveFromScreenCoordinates, moveToScreenCoordinates,); | ||
} | ||
|
||
private static getDeviceScreenCoordinates(screenSize: RectReturn, coordinates: ICoordinates): ICoordinates { | ||
return { | ||
x: Math.round(screenSize.width * (coordinates.x / 100)), | ||
y: Math.round(screenSize.height * (coordinates.y / 100)), | ||
}; | ||
} | ||
|
||
private static async swipe(from: ICoordinates, to: ICoordinates) { | ||
await driver.performActions([ | ||
{ | ||
type: "pointer", | ||
id: "finger1", | ||
parameters: { pointerType: "touch" }, | ||
actions: [ | ||
{ type: "pointerMove", duration: 0, x: from.x, y: from.y }, | ||
{ type: "pointerDown", button: 0 }, | ||
{ type: "pause", duration: 100 }, | ||
{ type: "pointerMove", duration: 1000, x: to.x, y: to.y }, | ||
{ type: "pointerUp", button: 0 }, | ||
], | ||
}, | ||
]); | ||
await driver.pause(1000); | ||
} | ||
} |
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,8 +1,17 @@ | ||
|
||
export default class HeaderComponent { | ||
|
||
public get productsTitle() { | ||
return $("//*[@text=\"PRODUCTS\"]"); | ||
private readonly basketLocator = "//android.view.ViewGroup[@content-desc='test-Cart']/android.view.ViewGroup/"; | ||
|
||
private get basketImg() { | ||
return $(`${this.basketLocator}android.widget.ImageView`); | ||
} | ||
|
||
public get basketProductsCount() { | ||
return $(`${this.basketLocator}android.widget.TextView`); | ||
} | ||
|
||
public async clickOnBasket() { | ||
await (await this.basketImg).click(); | ||
} | ||
} |
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,5 @@ | ||
export default interface IUserInformation { | ||
firstName: string, | ||
lastName: string, | ||
zipCode: 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,15 @@ | ||
|
||
export default class CartPage { | ||
|
||
private get checkoutBtn() { | ||
return $("//*[@text=\"CHECKOUT\"]"); | ||
} | ||
|
||
public get yourCartTitle() { | ||
return $("//*[@text=\"YOUR CART\"]"); | ||
} | ||
|
||
public async clickOnCheckoutBtn() { | ||
await (await this.checkoutBtn).click(); | ||
} | ||
} |
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 default class CheckoutCompletePage { | ||
|
||
public get checkoutCompleteTitle() { | ||
return $("//*[@text=\"CHECKOUT: COMPLETE!\"]"); | ||
} | ||
} |
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,34 @@ | ||
import IUserInformation from "../interfaces/IUserInformation"; | ||
|
||
export default class CheckoutInformationPage { | ||
|
||
private get firstNameField() { | ||
return $("~test-First Name"); | ||
} | ||
|
||
private get lastNameField() { | ||
return $("~test-Last Name"); | ||
} | ||
|
||
private get zipField() { | ||
return $("~test-Zip/Postal Code"); | ||
} | ||
|
||
private get continueBtn() { | ||
return $("//*[@text=\"CONTINUE\"]"); | ||
} | ||
|
||
public get checkoutInformationTitle() { | ||
return $("//*[@text=\"CHECKOUT: INFORMATION\"]"); | ||
} | ||
|
||
public async fillUserInformation({ firstName, lastName, zipCode }: IUserInformation) { | ||
await (await this.firstNameField).setValue(firstName); | ||
await (await this.lastNameField).setValue(lastName); | ||
await (await this.zipField).setValue(zipCode); | ||
} | ||
|
||
public async clickOnContinueBtn() { | ||
await (await this.continueBtn).click(); | ||
} | ||
} |
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,15 @@ | ||
|
||
export default class CheckoutOverviewPage { | ||
|
||
private get finishBtn() { | ||
return $("//*[@text=\"FINISH\"]"); | ||
} | ||
|
||
public get checkoutOverviewTitle() { | ||
return $("//*[@text=\"CHECKOUT: OVERVIEW\"]"); | ||
} | ||
|
||
public async clickOnFinishBtn() { | ||
await (await this.finishBtn).click(); | ||
} | ||
} |
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
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,40 @@ | ||
import { AccountType } from "../../../src/AccountType"; | ||
import Credentials from "../../../src/Credentials"; | ||
import CartPage from "../../../src/pages/CartPage"; | ||
import CheckoutCompletePage from "../../../src/pages/CheckoutCompletePage"; | ||
import CheckoutInformationPage from "../../../src/pages/CheckoutInformationPage"; | ||
import CheckoutOverviewPage from "../../../src/pages/CheckoutOverviewPage"; | ||
import InventoryPage from "../../../src/pages/InventoryPage"; | ||
import LoginPage from "../../../src/pages/LoginPage"; | ||
import Swipe from "../../../src/Swipe"; | ||
|
||
describe("Product order verification tests", () => { | ||
it("Product order (positive flow)", async () => { | ||
const loginPage = new LoginPage(); | ||
const inventoryPage = new InventoryPage(); | ||
const cartPage = new CartPage(); | ||
const checkoutInformationPage = new CheckoutInformationPage(); | ||
const checkoutOverviewPage = new CheckoutOverviewPage(); | ||
const checkoutCompletePage = new CheckoutCompletePage(); | ||
const user = { | ||
firstName: "Vadym", | ||
lastName: "Nastoiashchyi", | ||
zipCode: "21000" | ||
}; | ||
|
||
await loginPage.logInWithCredentials(Credentials.getUserCredentials(AccountType.Standard)); | ||
await expect((await inventoryPage.productsTitle)).toBeDisplayed(); | ||
await inventoryPage.clickOnFirstAddToCardBtn(); | ||
await expect(await (await inventoryPage.header.basketProductsCount).getText()).toEqual("1"); | ||
await inventoryPage.header.clickOnBasket(); | ||
await expect(await (await cartPage.yourCartTitle).getText()).toEqual("YOUR CART"); | ||
await cartPage.clickOnCheckoutBtn(); | ||
await expect(await (await checkoutInformationPage.checkoutInformationTitle).getText()).toEqual("CHECKOUT: INFORMATION"); | ||
await checkoutInformationPage.fillUserInformation(user); | ||
await checkoutInformationPage.clickOnContinueBtn(); | ||
await expect(await (await checkoutOverviewPage.checkoutOverviewTitle).getText()).toEqual("CHECKOUT: OVERVIEW"); | ||
await Swipe.down(); | ||
await checkoutOverviewPage.clickOnFinishBtn(); | ||
await expect(await (await checkoutCompletePage.checkoutCompleteTitle).getText()).toEqual("CHECKOUT: COMPLETE!"); | ||
}); | ||
}); |
File renamed without changes.