Skip to content
Open
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
8 changes: 2 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# .github/workflows/playwright-daily.yml
# Runs Playwright test shards every day at **11 : 42 AM IST** (06 : 12 UTC)
# plus anytime you trigger it manually from the Actions tab.

name: Run Playwright tests

on:
schedule:
- cron: '30 3 * * 1-5'
push:
workflow_dispatch:


jobs:
run-tests:
name: Run Playwright shards
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default defineConfig({
use: {
baseURL: 'https://demo.alphabin.co/',
headless: true,
trace: 'on-first-retry',
trace: 'on',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
Expand Down
263 changes: 20 additions & 243 deletions tests/example.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,25 @@ async function logout() {
await allPages.loginPage.clickOnLogoutButton();
}

test('Verify that user can login and logout successfully', async () => {
await login();
await logout();

// Configure retries for this test only
test.describe.configure({ retries: 2 });

test('Verify that user can login and logout successfully', async ({ page }) => {
await test.step('Login', async () => {
if (test.info().retry === 0) {
// First attempt → force failure
expect(false).toBe(true);
} else {
// Retry attempt → perform actual login
await login();
}
});

await test.step('Logout', async () => {
await page.waitForTimeout(2000); // Simulate some wait time before logout
await logout();
});
});

test('Verify that user can update personal information', async () => {
Expand Down Expand Up @@ -97,25 +113,7 @@ test('Verify that the New User is able to add Addresses in the Address section',
await allPages.userPage.fillAddressForm();
});

test('Verify that User Can Complete the Journey from Login to Order Placement', async () => {
const productName = 'GoPro HERO10 Black';
await login();
await allPages.inventoryPage.clickOnShopNowButton();
await allPages.inventoryPage.clickOnAllProductsLink();
await allPages.inventoryPage.searchProduct(productName);
await allPages.inventoryPage.verifyProductTitleVisible(productName);
await allPages.inventoryPage.clickOnAddToCartIcon();

await allPages.cartPage.clickOnCartIcon();
await allPages.cartPage.verifyCartItemVisible(productName);
await allPages.cartPage.clickOnCheckoutButton();
await allPages.checkoutPage.verifyCheckoutTitle();
await allPages.checkoutPage.verifyProductInCheckout(productName);
await allPages.checkoutPage.selectCashOnDelivery();
await allPages.checkoutPage.verifyCashOnDeliverySelected();
await allPages.checkoutPage.clickOnPlaceOrder();
await allPages.checkoutPage.verifyOrderPlacedSuccessfully();
});


test('Verify user can place and cancel an order', async () => {
const productName = 'GoPro HERO10 Black';
Expand Down Expand Up @@ -175,227 +173,6 @@ test('Verify user can place and cancel an order', async () => {
})
});

test('Verify that a New User Can Successfully Complete the Journey from Registration to a Single Order Placement', async () => {
// fresh test data
const email = `test+${Date.now()}@test.com`;
const firstName = 'Test';
const lastName = 'User';

let productName;
let productPrice;
let productReviewCount;

await test.step('Verify that user can register successfully', async () => {
await allPages.loginPage.clickOnUserProfileIcon();
await allPages.loginPage.validateSignInPage();
await allPages.loginPage.clickOnSignupLink();
await allPages.signupPage.assertSignupPage();
await allPages.signupPage.signup(firstName, lastName, email, process.env.PASSWORD);
await allPages.signupPage.verifySuccessSignUp();
})

await test.step('Verify that user can login successfully', async () => {
await allPages.loginPage.validateSignInPage();
await allPages.loginPage.login(email, process.env.PASSWORD);
await allPages.loginPage.verifySuccessSignIn();
await expect(allPages.homePage.getHomeNav()).toBeVisible({ timeout: 30000 });
})

await test.step('Navigate to all product and add to wishlist section', async () => {
await allPages.homePage.clickAllProductsNav();
await allPages.allProductsPage.assertAllProductsTitle();

productName = await allPages.allProductsPage.getNthProductName(1);
productPrice = await allPages.allProductsPage.getNthProductPrice(1);
productReviewCount = await allPages.allProductsPage.getNthProductReviewCount(1);

await allPages.allProductsPage.clickNthProductWishlistIcon(1);
await expect(allPages.allProductsPage.getNthProductWishlistIconCount(1)).toContainText('1');
await allPages.allProductsPage.clickNthProduct(1);

await allPages.productDetailsPage.assertProductNameTitle(productName);
await allPages.productDetailsPage.assertProductPrice(productName, productPrice);
await allPages.productDetailsPage.assertProductReviewCount(productName, productReviewCount);
await expect(allPages.allProductsPage.getNthProductWishlistIconCount(1)).toContainText('1');
})

await test.step('Add product to cart, add new address and checkout', async () => {
await allPages.productDetailsPage.clickAddToCartButton();

await allPages.productDetailsPage.clickCartIcon();
await allPages.cartPage.assertYourCartTitle();
await expect(allPages.cartPage.getCartItemName()).toContainText(productName, { timeout: 10000 });
await expect(allPages.cartPage.getCartItemPrice()).toContainText(productPrice);
await expect(allPages.cartPage.getCartItemQuantity()).toContainText('1');
await allPages.cartPage.clickIncreaseQuantityButton();
await expect(allPages.cartPage.getCartItemQuantity()).toContainText('2');

const cleanPrice = productPrice.replace(/[₹,]/g, '');
const priceValue = parseFloat(cleanPrice) * 2;
await expect(allPages.cartPage.getTotalValue()).toContainText(
priceValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
);
await allPages.cartPage.clickOnCheckoutButton();

// Fill shipping address and save
await allPages.checkoutPage.verifyCheckoutTitle();
await allPages.checkoutPage.fillShippingAddress(
firstName, email, 'New York', 'New York', '123 Main St', '10001', 'United States'
);
await allPages.checkoutPage.clickSaveAddressButton();
await allPages.checkoutPage.assertAddressAddedToast();

// COD, verify summary, place order
await allPages.checkoutPage.selectCashOnDelivery();
await allPages.checkoutPage.verifyCheckoutTitle();
await allPages.checkoutPage.assertOrderSummaryTitle();
await expect(allPages.checkoutPage.getOrderSummaryImage()).toBeVisible();
await expect(allPages.checkoutPage.getOrderSummaryProductName()).toContainText(productName);
await allPages.checkoutPage.verifyProductInCheckout(productName);
await expect(allPages.checkoutPage.getOrderSummaryProductQuantity()).toContainText('2');
await expect(allPages.checkoutPage.getOrderSummaryProductPrice()).toContainText(productPrice);

const subtotalValue = parseFloat(cleanPrice) * 2;
const formattedSubtotal = subtotalValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
await expect(await allPages.checkoutPage.getOrderSummarySubtotalValue()).toContain(formattedSubtotal);
await expect(allPages.checkoutPage.getOrderSummaryShippingValue()).toContainText('Free');
await allPages.checkoutPage.clickOnPlaceOrder();

// Order details and return to home
await allPages.orderDetailsPage.assertOrderDetailsTitle();
await allPages.orderDetailsPage.assertOrderPlacedName();
await allPages.orderDetailsPage.assertOrderPlacedMessage();
await allPages.orderDetailsPage.assertOrderPlacedDate();
await allPages.orderDetailsPage.assertOrderInformationTitle();
await allPages.orderDetailsPage.assertOrderConfirmedTitle();
await allPages.orderDetailsPage.assertOrderConfirmedMessage();
await allPages.orderDetailsPage.assertShippingDetailsTitle();
await allPages.orderDetailsPage.assertShippingEmailValue(email);
await allPages.orderDetailsPage.assertPaymentMethodAmount(formattedSubtotal);
await allPages.orderDetailsPage.assertDeliveryAddressLabel();
await allPages.orderDetailsPage.assertDeliveryAddressValue();
await allPages.orderDetailsPage.assertContinueShoppingButton();

await allPages.orderDetailsPage.assertOrderSummaryTitle();
await allPages.orderDetailsPage.assertOrderSummaryProductName(productName);
await allPages.orderDetailsPage.assertOrderSummaryProductQuantity('2');
await allPages.orderDetailsPage.assertOrderSummaryProductPrice(productPrice);
await allPages.orderDetailsPage.assertOrderSummarySubtotalValue(formattedSubtotal);
await allPages.orderDetailsPage.assertOrderSummaryShippingValue('Free');
await allPages.orderDetailsPage.assertOrderSummaryTotalValue(formattedSubtotal);
await allPages.orderDetailsPage.clickBackToHomeButton();
});
});

test('Verify that user add product to cart before logging in and then complete order after logging in', async () => {
await test.step('Navigate and add product to cart before logging in', async () => {
await allPages.homePage.clickOnShopNowButton();
await allPages.homePage.clickProductImage();
await allPages.homePage.clickAddToCartButton();
await allPages.homePage.validateAddCartNotification();
await allPages.loginPage.clickOnUserProfileIcon();
})
await test.step('Login and complete order', async () => {
await login();
await allPages.cartPage.clickOnCartIcon();
await allPages.cartPage.clickOnCheckoutButton();
await allPages.checkoutPage.verifyCheckoutTitle();
await allPages.checkoutPage.selectCashOnDelivery();
await allPages.checkoutPage.verifyCashOnDeliverySelected();
await allPages.checkoutPage.clickOnPlaceOrder();
await allPages.checkoutPage.verifyOrderPlacedSuccessfully();
})
});

test('Verify that user can filter products by price range', async () => {
await login();
await allPages.homePage.clickOnShopNowButton();
await allPages.homePage.clickOnFilterButton();
await allPages.homePage.AdjustPriceRangeSlider('10000', '20000');
await allPages.homePage.clickOnFilterButton();
});

test('Verify if user can add product to wishlist, moves it to card and then checks out', async () => {
await login();

await test.step('Add product to wishlistand then add to cart', async () => {
await allPages.homePage.clickOnShopNowButton();
await allPages.inventoryPage.addToWishlist();
await allPages.inventoryPage.assertWishlistIcon();
await allPages.inventoryPage.clickOnWishlistIconHeader();
await allPages.inventoryPage.assertWishlistPage();
await allPages.inventoryPage.clickOnWishlistAddToCard();
})

await test.step('Checkout product added to cart', async () => {
await allPages.cartPage.clickOnCartIcon();
await allPages.cartPage.clickOnCheckoutButton();
await allPages.checkoutPage.verifyCheckoutTitle();
await allPages.checkoutPage.selectCashOnDelivery();
await allPages.checkoutPage.verifyCashOnDeliverySelected();
await allPages.checkoutPage.clickOnPlaceOrder();
await allPages.checkoutPage.verifyOrderPlacedSuccessfully();
})

});

test('Verify new user views and cancels an order in my orders', async () => {
const email = `test+${Date.now()}@test.com`;
const firstName = 'Test';
const lastName = 'User';

let productName= `Rode NT1-A Condenser Mic`;

await test.step('Verify that user can register successfully', async () => {
await allPages.loginPage.clickOnUserProfileIcon();
await allPages.loginPage.validateSignInPage();
await allPages.loginPage.clickOnSignupLink();
await allPages.signupPage.assertSignupPage();
await allPages.signupPage.signup(firstName, lastName, email, process.env.PASSWORD);
await allPages.signupPage.verifySuccessSignUp();
})

await test.step('Verify that user can login successfully', async () => {
await allPages.loginPage.validateSignInPage();
await allPages.loginPage.login(email, process.env.PASSWORD);
await allPages.loginPage.verifySuccessSignIn();
await expect(allPages.homePage.getHomeNav()).toBeVisible({ timeout: 30000 });
})

await test.step('Navigate to All Products and add view details of a random product', async () => {
await allPages.homePage.clickAllProductsNav();
await allPages.allProductsPage.assertAllProductsTitle();
productName = await allPages.allProductsPage.getNthProductName(1);
await allPages.allProductsPage.clickNthProduct(1);
await allPages.productDetailsPage.clickAddToCartButton();
})

await test.step('Add product to cart, add new address and checkout', async () => {
await allPages.productDetailsPage.clickCartIcon();
await allPages.cartPage.assertYourCartTitle();
await expect(allPages.cartPage.getCartItemName()).toContainText(productName, { timeout: 10000 });
await allPages.cartPage.clickOnCheckoutButton();
await allPages.checkoutPage.verifyCheckoutTitle();
await allPages.checkoutPage.fillShippingAddress(
firstName, email, 'New York', 'New York', '123 Main St', '10001', 'United States'
);
await allPages.checkoutPage.clickSaveAddressButton();
await allPages.checkoutPage.assertAddressAddedToast();
})

await test.step('Complete order and verify in my orders', async () => {
await allPages.checkoutPage.selectCashOnDelivery();
await allPages.checkoutPage.verifyCheckoutTitle();
await allPages.checkoutPage.clickOnPlaceOrder();
await allPages.checkoutPage.verifyOrderPlacedSuccessfully();
await allPages.inventoryPage.clickOnContinueShopping();

await allPages.loginPage.clickOnUserProfileIcon();
await allPages.orderPage.clickOnMyOrdersTab();
await allPages.orderPage.clickCancelOrderButton();
await allPages.orderPage.confirmCancellation();
});
});

test('Verify That a New User Can Successfully Complete the Journey from Registration to a Multiple Order Placement', async () => {
const email = `test+${Date.now()}@test.com`;
Expand Down
Loading