-
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 #5 from VadimNastoyashchy/develop
Added test for product filter scenario
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cucumberautocomplete.steps": [ | ||
"features/step-definitions/*.ts", | ||
], | ||
"cucumberautocomplete.strictGherkinCompletion": true | ||
} |
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 @@ | ||
class FilterComponent { | ||
private get nameZtoA() { | ||
return $("//*[@text=\"Name (Z to A)\"]"); | ||
} | ||
|
||
public async clickOnNameZtoA() { | ||
await (await this.nameZtoA).click(); | ||
} | ||
} | ||
|
||
export default new FilterComponent(); |
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,20 +1,40 @@ | ||
import HeaderComponent from "../components/HeaderComponent"; | ||
import FilterComponent from "../components/FilterComponent"; | ||
|
||
class InventoryPage { | ||
|
||
public header = HeaderComponent; | ||
public filter = FilterComponent; | ||
|
||
private get addToCartBtn() { | ||
return $$("//*[@text=\"ADD TO CART\"]"); | ||
} | ||
|
||
private get productItemTitles() { | ||
return $$("//android.widget.TextView[@content-desc=\"test-Item title\"]"); | ||
} | ||
|
||
private get filterBtn() { | ||
return $("//android.view.ViewGroup[@content-desc=\"test-Modal Selector Button\"]"); | ||
} | ||
|
||
public get productsTitle() { | ||
return $("//*[@text=\"PRODUCTS\"]"); | ||
} | ||
|
||
public async clickOnFirstAddToCardBtn() { | ||
await (await this.addToCartBtn[0]).click(); | ||
} | ||
|
||
public async clickOnFilterBtn() { | ||
await (await this.filterBtn).click(); | ||
} | ||
|
||
public async checkProductItemsIsSortedFromZtoA() { | ||
const firstProductTitle = await (await this.productItemTitles[0]).getText(); | ||
const secondProductTitle = await (await this.productItemTitles[1]).getText(); | ||
await expect(firstProductTitle.charCodeAt(0)).toBeGreaterThan(secondProductTitle.charCodeAt(0)); | ||
} | ||
} | ||
|
||
export default new InventoryPage(); |
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,7 @@ | ||
Feature: Swaglabs app product filter | ||
|
||
Scenario Outline: As a standard user, I can filter the product | ||
|
||
Given I am logged in the app | ||
When I chose NAME(Z-A) in filter options | ||
Then products should be sorted From Z to A |
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,12 @@ | ||
import {Then, When} from "@wdio/cucumber-framework"; | ||
import InventoryPage from "../pageobjects/pages/InventoryPage"; | ||
|
||
When(/^I chose NAME\(Z-A\) in filter options$/, async () => { | ||
await InventoryPage.clickOnFilterBtn(); | ||
await InventoryPage.filter.clickOnNameZtoA(); | ||
await expect((await InventoryPage.productsTitle)).toBeDisplayed(); | ||
}); | ||
|
||
Then(/^products should be sorted From Z to A$/, async () => { | ||
await InventoryPage.checkProductItemsIsSortedFromZtoA(); | ||
}); |