-
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.
Merge pull request #4 from VadimNastoyashchy/develop
Develop
- Loading branch information
Showing
19 changed files
with
285 additions
and
29 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,11 @@ | ||
Feature: Swaglabs app Log In | ||
|
||
Scenario Outline: As a problem user, I can log into Swaglabs application | ||
|
||
Given I am on the login page | ||
When I login with <username> and <password> | ||
Then I redirected to the inventory page with title <title> | ||
|
||
Examples: | ||
| username | password | title | | ||
| problem_user | secret_sauce | PRODUCTS | |
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,5 @@ | ||
export enum AccountType { | ||
Standard = "standard", | ||
LocKed = "locked", | ||
Problem = "problem", | ||
} |
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,22 @@ | ||
import {AccountType} from "./AccountType"; | ||
|
||
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" | ||
} | ||
}; | ||
|
||
public static getUserCredentials(accountType: AccountType) { | ||
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,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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class HeaderComponent { | ||
|
||
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(); | ||
} | ||
} | ||
|
||
export default new HeaderComponent(); |
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,16 @@ | ||
class CartPage { | ||
|
||
private get checkoutBtn() { | ||
return $("//*[@text=\"CHECKOUT\"]"); | ||
} | ||
|
||
public get yourCartTitle() { | ||
return $("//*[@text=\"YOUR CART\"]"); | ||
} | ||
|
||
public async clickOnCheckoutBtn() { | ||
await (await this.checkoutBtn).click(); | ||
} | ||
} | ||
|
||
export default new CartPage(); |
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,8 @@ | ||
class CheckoutCompletePage { | ||
|
||
public get checkoutCompleteTitle() { | ||
return $("//*[@text=\"CHECKOUT: COMPLETE!\"]"); | ||
} | ||
} | ||
|
||
export default new CheckoutCompletePage(); |
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 @@ | ||
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: string, lastName: string, zipCode: string) { | ||
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(); | ||
} | ||
} | ||
|
||
export default new CheckoutInformationPage(); |
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,16 @@ | ||
class CheckoutOverviewPage { | ||
|
||
private get finishBtn() { | ||
return $("//*[@text=\"FINISH\"]"); | ||
} | ||
|
||
public get checkoutOverviewTitle() { | ||
return $("//*[@text=\"CHECKOUT: OVERVIEW\"]"); | ||
} | ||
|
||
public async clickOnFinishBtn() { | ||
await (await this.finishBtn).click(); | ||
} | ||
} | ||
|
||
export default new CheckoutOverviewPage(); |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
class LoginPage { | ||
|
||
private get inputEmail() { | ||
|
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,14 @@ | ||
Feature: Swaglabs app product order | ||
|
||
Scenario Outline: As a standard user, I can order the product | ||
|
||
Given I am logged in the app | ||
And I want to add one product into the basket | ||
And I complete first order step | ||
When I fill <firstName> and <lastName> and <zipCode> on the second order step | ||
Then I click on the finnish button on the third order step | ||
And I will see page title <title> | ||
|
||
Examples: | ||
| firstName | lastName | zipCode | | title | | ||
| Vadym | Nastoiashchyi | 21000 | | CHECKOUT: COMPLETE! | |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {Given, Then, When} from "@wdio/cucumber-framework"; | ||
import LoginPage from "../pageobjects/pages/LoginPage"; | ||
import InventoryPage from "../pageobjects/pages/InventoryPage"; | ||
|
||
Given(/^I am on the login page/, async () => { | ||
await expect(await LoginPage.swaglabsImg).toBeDisplayed(); | ||
await expect(await LoginPage.logInButton).toBeDisplayed(); | ||
}); | ||
|
||
When(/^I login with (\w+) and (.+)$/, async (username, password) => { | ||
await LoginPage.logInWithCredentials(username, password); | ||
}); | ||
|
||
Then(/^I redirected to the inventory page with title (.*)$/, async (title) => { | ||
await expect(await (await InventoryPage.productsTitle).getText()).toEqual(title); | ||
}); |
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,43 @@ | ||
import {Given, Then, When} from "@wdio/cucumber-framework"; | ||
import Credentials from "../pageobjects/Credentials"; | ||
import {AccountType} from "../pageobjects/AccountType"; | ||
import LoginPage from "../pageobjects/pages/LoginPage"; | ||
import InventoryPage from "../pageobjects/pages/InventoryPage"; | ||
import CartPage from "../pageobjects/pages/CartPage"; | ||
import CheckoutInformationPage from "../pageobjects/pages/CheckoutInformationPage"; | ||
import CheckoutOverviewPage from "../pageobjects/pages/CheckoutOverviewPage"; | ||
import Swipe from "../pageobjects/Swipe"; | ||
import CheckoutCompletePage from "../pageobjects/pages/CheckoutCompletePage"; | ||
|
||
Given(/^I am logged in the app/, async () => { | ||
const {userName, password} = Credentials.getUserCredentials(AccountType.Standard); | ||
await LoginPage.logInWithCredentials(userName, password); | ||
await expect((await InventoryPage.productsTitle)).toBeDisplayed(); | ||
}); | ||
|
||
When(/^I want to add one product into the basket/, async () => { | ||
await InventoryPage.clickOnFirstAddToCardBtn(); | ||
await expect(await (await InventoryPage.header.basketProductsCount).getText()).toEqual("1"); | ||
}); | ||
|
||
When(/^I complete first order step/, async () => { | ||
await InventoryPage.header.clickOnBasket(); | ||
await expect(await (await CartPage.yourCartTitle).getText()).toEqual("YOUR CART"); | ||
}); | ||
|
||
When(/^I fill (\w+) and (\w+) and (\w+) on the second order step/, async (firstName, lastName, zipCode) => { | ||
await CartPage.clickOnCheckoutBtn(); | ||
await expect(await (await CheckoutInformationPage.checkoutInformationTitle).getText()).toEqual("CHECKOUT: INFORMATION"); | ||
await CheckoutInformationPage.fillUserInformation(firstName, lastName, zipCode); | ||
await CheckoutInformationPage.clickOnContinueBtn(); | ||
await expect(await (await CheckoutOverviewPage.checkoutOverviewTitle).getText()).toEqual("CHECKOUT: OVERVIEW"); | ||
await Swipe.down(); | ||
}); | ||
|
||
Then(/^I click on the finnish button on the third order step/, async () => { | ||
await CheckoutOverviewPage.clickOnFinishBtn(); | ||
}); | ||
|
||
Then(/^I will see page title (.*)/, async (title) => { | ||
await expect(await (await CheckoutCompletePage.checkoutCompleteTitle).getText()).toEqual(title); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.