Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,17 @@ jobs:
node-version: '18'
- name: Create .env file
run: |
echo "USERNAME=${{ secrets.USERNAME }}" >> .env
echo "PASSWORD=${{ secrets.PASSWORD }}" >> .env

echo "USERNAME=${{ secrets.USERNAME }}" >> .env
echo "USERNAME1=${{ secrets.USERNAME1 }}" >> .env
echo "PASSWORD=${{ secrets.PASSWORD }}" >> .env
echo "NEW_PASSWORD=${{ secrets.NEW_PASSWORD }}" >> .env
echo "FIRST_NAME=${{ secrets.FIRST_NAME }}" >> .env
echo "STREET_NAME=${{ secrets.STREET_NAME }}" >> .env
echo "CITY=${{ secrets.CITY }}" >> .env
echo "STATE=${{ secrets.STATE }}" >> .env
echo "COUNTRY=${{ secrets.COUNTRY }}" >> .env
echo "ZIP_CODE=${{ secrets.ZIP_CODE }}" >> .env

- name: Cache npm dependencies
uses: actions/cache@v3
with:
Expand Down
58 changes: 29 additions & 29 deletions pages/AllPages.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import LoginPage from "./LoginPage";
import InventoryPage from "./InventoryPage";
import SignupPage from "./SignupPage";
import HomePage from "./HomePage";
import AllProductsPage from "./AllProductsPage";
import ProductDetailsPage from "./ProductDetailsPage";
import CartPage from "./CartPage";
import CheckoutPage from "./CheckoutPage";
import OrderPage from "./OrderPage"; // Import OrderPage
import UserPage from "./UserPage"; // Import UserPage
import OrderDetailsPage from "./OrderDetailsPage";

class AllPages {
constructor(page) {
this.page = page;
this.loginPage = new LoginPage(page);
this.inventoryPage = new InventoryPage(page);
this.signupPage = new SignupPage(page);
this.homePage = new HomePage(page);
this.allProductsPage = new AllProductsPage(page);
this.productDetailsPage = new ProductDetailsPage(page);
this.cartPage = new CartPage(page);
this.checkoutPage = new CheckoutPage(page);
this.orderPage = new OrderPage(page); // Instantiate OrderPage
this.userPage = new UserPage(page); // Instantiate UserPage
this.orderDetailsPage = new OrderDetailsPage(page);
}
}

import LoginPage from "./LoginPage";
import InventoryPage from "./InventoryPage";
import SignupPage from "./SignupPage";
import HomePage from "./HomePage";
import AllProductsPage from "./AllProductsPage";
import ProductDetailsPage from "./ProductDetailsPage";
import CartPage from "./CartPage";
import CheckoutPage from "./CheckoutPage";
import OrderPage from "./OrderPage"; // Import OrderPage
import UserPage from "./UserPage"; // Import UserPage
import OrderDetailsPage from "./OrderDetailsPage";
class AllPages {
constructor(page) {
this.page = page;
this.loginPage = new LoginPage(page);
this.inventoryPage = new InventoryPage(page);
this.signupPage = new SignupPage(page);
this.homePage = new HomePage(page);
this.allProductsPage = new AllProductsPage(page);
this.productDetailsPage = new ProductDetailsPage(page);
this.cartPage = new CartPage(page);
this.checkoutPage = new CheckoutPage(page);
this.orderPage = new OrderPage(page); // Instantiate OrderPage
this.userPage = new UserPage(page); // Instantiate UserPage
this.orderDetailsPage = new OrderDetailsPage(page);
}
}
export default AllPages;
127 changes: 64 additions & 63 deletions pages/AllProductsPage.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
import BasePage from './BasePage.js';
import { expect } from '@playwright/test';

class AllProductsPage extends BasePage{

/**
* @param {import('@playwright/test').Page} page
*/
constructor(page) {
super(page);
this.page = page;
}

locators = {
allProductsTitle: `//h1[text()="All Products"]`,
nthProduct: `[href*="/product-detail/product"]`,
nthProductName: `[href*="/product-detail/product"] h2`,
nthProductPrice: `[href*="/product-detail/product"] p`,
nthProductReviewCount: `[href*="/product-detail/product"] h2 + div span.text-sm`,
nthProductWishlistIcon: '[aria-label="heart"]',
nthProductWishlistIconCount: '.bg-orange-100'
}

async assertAllProductsTitle() {
await expect(this.page.locator(this.locators.allProductsTitle)).toBeVisible();
}

getNthProduct(n) {
return this.page.locator(this.locators.nthProduct).nth(n - 1)
}

async clickNthProduct(n) {
await this.getNthProduct(n).click();
}

getNthProductName(n) {
return this.page.locator(this.locators.nthProductName).nth(n - 1).textContent();
}

getNthProductPrice(n) {
return this.page.locator(this.locators.nthProductPrice).nth(n - 1).textContent();
}

getNthProductReviewCount(n) {
return this.page.locator(this.locators.nthProductReviewCount).nth(n - 1).textContent();
}

getNthProductWishlistIcon(n) {
return this.page.locator(this.locators.nthProductWishlistIcon).nth(n - 1)
}

async clickNthProductWishlistIcon(n) {
await this.getNthProduct(n).hover()
await this.getNthProductWishlistIcon(n).click();
await expect(this.page.getByText('Added to the wishlist')).toBeVisible();
}

getNthProductWishlistIconCount(n) {
return this.page.locator(this.locators.nthProductWishlistIconCount).nth(n - 1);
}

}

import BasePage from './BasePage.js';
import { expect } from '@playwright/test';

class AllProductsPage extends BasePage{

/**
* @param {import('@playwright/test').Page} page
*/
constructor(page) {
super(page);
this.page = page;
}

locators = {
allProductsTitle: `//h1[text()="All Products"]`,
nthProduct: `[href*="/product-detail/product"]`,
nthProductName: `[href*="/product-detail/product"] h2`,
nthProductPrice: `[href*="/product-detail/product"] p`,
nthProductReviewCount: `[href*="/product-detail/product"] h2 + div span.text-sm`,
nthProductWishlistIcon: '[aria-label="heart"]',
nthProductWishlistIconCount: '.bg-orange-100'

}

async assertAllProductsTitle() {
await expect(this.page.locator(this.locators.allProductsTitle)).toBeVisible();
}

getNthProduct(n) {
return this.page.locator(this.locators.nthProduct).nth(n - 1)
}

async clickNthProduct(n) {
await this.getNthProduct(n).click();
}

getNthProductName(n) {
return this.page.locator(this.locators.nthProductName).nth(n - 1).textContent();
}

getNthProductPrice(n) {
return this.page.locator(this.locators.nthProductPrice).nth(n - 1).textContent();
}

getNthProductReviewCount(n) {
return this.page.locator(this.locators.nthProductReviewCount).nth(n - 1).textContent();
}

getNthProductWishlistIcon(n) {
return this.page.locator(this.locators.nthProductWishlistIcon).nth(n - 1)
}

async clickNthProductWishlistIcon(n) {
await this.getNthProduct(n).hover()
await this.getNthProductWishlistIcon(n).click();
await expect(this.page.getByText('Added to the wishlist')).toBeVisible();
}

getNthProductWishlistIconCount(n) {
return this.page.locator(this.locators.nthProductWishlistIconCount).nth(n - 1);
}

}

export default AllProductsPage;
38 changes: 19 additions & 19 deletions pages/BasePage.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Page } from '@playwright/test';

class BasePage {
/**
* @param {Page} page
*/
constructor(page) {
this.page = page;
}

async navigateTo(url) {
await this.page.goto(url);
}

async getPageTitle() {
return await this.page.title();
}
}

import { Page } from '@playwright/test';
class BasePage {
/**
* @param {Page} page
*/
constructor(page) {
this.page = page;
}
async navigateTo(url) {
await this.page.goto(url);
}
async getPageTitle() {
return await this.page.title();
}
}
export default BasePage;
Loading
Loading