Skip to content

Commit

Permalink
Added test for footer component
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimNastoyashchy committed Dec 12, 2022
1 parent 1c20759 commit e6da3f2
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
12 changes: 12 additions & 0 deletions features/footer_component.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: Swaglabs app footer component

Scenario Outline: As a standard user, I can order the product

Given I am logged in the app
When I scroll to the app footer
Then App footer is displayed
And I will see footer social media links
And I will see footer corporation information title <title> and subtitle <subtitle>
Examples:
| title | subtitle |
| © 2022 Sauce Labs. All Rights Reserved. | Terms of Service \| Privacy Policy |
41 changes: 41 additions & 0 deletions features/pageobjects/components/FooterComponent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class FooterComponent {

private readonly footerContainerLocator = "//android.widget.ScrollView[@content-desc=\"test-PRODUCTS\"]/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup";

private get twitterLink() {
return $(`${this.footerContainerLocator}/android.widget.TextView[1]`);
}

private get facebookLink() {
return $(`${this.footerContainerLocator}/android.widget.TextView[2]`);
}

private get googlePlusLink() {
return $(`${this.footerContainerLocator}/android.widget.TextView[3]`);
}

private get linkedinLink() {
return $(`${this.footerContainerLocator}/android.widget.TextView[4]`);
}

public get container() {
return $(this.footerContainerLocator);
}

public get corpInfoTitle() {
return $("//*[@text=\"© 2022 Sauce Labs. All Rights Reserved.\"]");
}

public get corpInfoSubTitle() {
return $("//*[@text=\"Terms of Service | Privacy Policy\"]");
}

public async checkFooterLinkIsDisplayed() {
await expect(await this.twitterLink).toBeDisplayed();
await expect(await this.facebookLink).toBeDisplayed();
await expect(await this.googlePlusLink).toBeDisplayed();
await expect(await this.linkedinLink).toBeDisplayed();
}
}

export default new FooterComponent();
2 changes: 2 additions & 0 deletions features/pageobjects/pages/InventoryPage.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import HeaderComponent from "../components/HeaderComponent";
import FilterComponent from "../components/FilterComponent";
import FooterComponent from "../components/FooterComponent";

class InventoryPage {

public header = HeaderComponent;
public filter = FilterComponent;
public footer = FooterComponent;

private get addToCartBtn() {
return $$("//*[@text=\"ADD TO CART\"]");
Expand Down
21 changes: 21 additions & 0 deletions features/step-definitions/footer.feature.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Then, When} from "@wdio/cucumber-framework";
import Swipe from "../pageobjects/Swipe";
import InventoryPage from "../pageobjects/pages/InventoryPage";

When(/^I scroll to the app footer$/, async () => {
await Swipe.down();
await Swipe.down();
});

Then(/^App footer is displayed$/, async () => {
await expect(await InventoryPage.footer.container).toBeDisplayed();
});

Then(/^I will see footer social media links$/, async () => {
await InventoryPage.footer.checkFooterLinkIsDisplayed();
});

Then(/^I will see footer corporation information title (.*) and subtitle (.*)$/, async (title, subTitle) => {
await expect(await (await InventoryPage.footer.corpInfoTitle).getText()).toEqual(title);
await expect(await (await InventoryPage.footer.corpInfoSubTitle).getText()).toEqual(subTitle);
});

0 comments on commit e6da3f2

Please sign in to comment.