Skip to content
Merged
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
29 changes: 29 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Playwright Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
playwright-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install dependencies
run: npm ci

- name: Install Playwright browsers
run: npx playwright install --with-deps

- name: Run Playwright tests
run: npx playwright test
83 changes: 83 additions & 0 deletions tests/E2E/endTests.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { test, expect} from '@playwright/test'
import { BASE_URL, USERNAME, PASSWORD } from '../../utils/envConfig'
import { ProductPage } from '../../pages/ProductPage'
import { LoginPage } from '../../pages/LoginPage'
import { LoginLocators } from '../../locators/LoginLocators'
import { CartPage } from '../../pages/CartPage'
import { CheckoutPage } from '../../pages/CheckoutPage'
import { checckoutData } from '../../test-data/checkoutData'
import { productsToCart } from '../../test-data/products'
import { CheckoutOverviewPage } from '../../pages/CheckoutOverviewPage'
import { FinalPage } from '../../pages/FinalPage'


test.describe("E2E End Page Validation", () => {
let loginPage: LoginPage
let productPage: ProductPage
let cartPage : CartPage
let checkoutPage : CheckoutPage
let checkoutOverview : CheckoutOverviewPage
let finalPage : FinalPage

test.beforeEach(async ({ page }) => {
loginPage = new LoginPage(page);
productPage = new ProductPage(page);
cartPage = new CartPage(page)
checkoutPage = new CheckoutPage(page)
checkoutOverview = new CheckoutOverviewPage(page)
finalPage = new FinalPage(page);

await page.goto(BASE_URL);
await loginPage.login(USERNAME, PASSWORD);

await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html");

await productPage.getSpecificProductDetails(productsToCart);
await productPage.clickOnCartLink();
await cartPage.clickCheckoutButton();
await checkoutPage.fillCheckoutDetail(checckoutData.firstName, checckoutData.lastName, checckoutData.postalCode);
await checkoutPage.clickOnContinue();
await checkoutOverview.clickOnFinish();
})

test("Validate checkout overview page UI and url", async({page})=>
{
await expect(page).toHaveURL("https://www.saucedemo.com/checkout-complete.html")
const elements = await finalPage.getFinalPageElements();
await expect(elements.backHomeBtn).toBeVisible()
await expect(elements.successMsg).toBeVisible()
await expect(elements.pageInfo).toBeVisible()
})

test("Validate the Success Message", async({page})=>
{
const message = await finalPage.getSuccessMsgText();
expect(message).toBe("Thank you for your order!")
})
test ("Validate BackHomeButton", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
})
test ("Validate BackHomeButton 1", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
})
test ("Validate BackHomeButton 2", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
})
test ("Validate BackHomeButton 4", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
})
test ("End to Test Validate BackHomeButton 1", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
})

})
18 changes: 9 additions & 9 deletions tests/E2E/finalPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CheckoutOverviewPage } from '../../pages/CheckoutOverviewPage'
import { FinalPage } from '../../pages/FinalPage'


test.describe("Final Page Validation", () => {
test.describe("E2E Final Page Validation", () => {
let loginPage: LoginPage
let productPage: ProductPage
let cartPage : CartPage
Expand All @@ -30,7 +30,7 @@ test.describe("Final Page Validation", () => {
await page.goto(BASE_URL);
await loginPage.login(USERNAME, PASSWORD);

await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html/EngineerB");
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html");

await productPage.getSpecificProductDetails(productsToCart);
await productPage.clickOnCartLink();
Expand All @@ -40,7 +40,7 @@ test.describe("Final Page Validation", () => {
await checkoutOverview.clickOnFinish();
})

test("Validate checkout overview page UI and url", async({page})=>
test(" e2e Validate checkout overview page UI and url", async({page})=>
{
await expect(page).toHaveURL("https://www.saucedemo.com/checkout-complete.html")
const elements = await finalPage.getFinalPageElements();
Expand All @@ -49,32 +49,32 @@ test.describe("Final Page Validation", () => {
await expect(elements.pageInfo).toBeVisible()
})

test.only("Validate the Success Message", async({page})=>
test("e2e Validate the Success Message", async({page})=>
{
const message = await finalPage.getSuccessMsgText();
expect(message).toBe("Thank you for your order!")
})
test ("Validate BackHomeButton", async({page})=>
test ("e2e Validate BackHomeButton", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
})
test ("Validate BackHomeButton 1", async({page})=>
test ("e2e Validate BackHomeButton 1", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
})
test ("Validate BackHomeButton 2", async({page})=>
test (" e2e Validate BackHomeButton 2", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
})
test ("Validate BackHomeButton 4", async({page})=>
test ("e2e Validate BackHomeButton 4", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
})
test ("Validate BackHomeButton 1", async({page})=>
test ("e2e Validate BackHomeButton 2", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
Expand Down
8 changes: 4 additions & 4 deletions tests/IntegrationTesting/finalPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test.describe("Final Page Validation", () => {
await checkoutOverview.clickOnFinish();
})

test("Validate checkout overview page UI and url", async({page})=>
test("int Validate checkout overview page UI and url", async({page})=>
{
await expect(page).toHaveURL("https://www.saucedemo.com/checkout-complete.html")
const elements = await finalPage.getFinalPageElements();
Expand All @@ -47,17 +47,17 @@ test.describe("Final Page Validation", () => {
await expect(elements.pageInfo).toBeVisible()
})

test.only("Validate the Success Message", async({page})=>
test("int Validate the Success Message", async({page})=>
{
const message = await finalPage.getSuccessMsgText();
expect(message).toBe("Thank you for your order!")
})
test ("Validate BackHomeButton", async({page})=>
test ("Int Validate BackHomeButton", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
})
test ("Validate BackHomeButton 1234", async({page})=>
test ("int Validate BackHomeButton 1234", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
Expand Down
6 changes: 3 additions & 3 deletions tests/Smoke/finalPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test.describe("Final Page Validation", () => {
await checkoutOverview.clickOnFinish();
})

test("Validate checkout overview page UI and url", async({page})=>
test("smoke Validate checkout overview page UI and url", async({page})=>
{
await expect(page).toHaveURL("https://www.saucedemo.com/checkout-complete.html")
const elements = await finalPage.getFinalPageElements();
Expand All @@ -47,12 +47,12 @@ test.describe("Final Page Validation", () => {
await expect(elements.pageInfo).toBeVisible()
})

test.only("Validate the Success Message", async({page})=>
test("smo Validate the Success Message", async({page})=>
{
const message = await finalPage.getSuccessMsgText();
expect(message).toBe("Thank you for your order!")
})
test ("Validate BackHomeButton", async({page})=>
test ("smoke Validate BackHomeButton", async({page})=>
{
await finalPage.clickOnBackHomeBtn();
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
Expand Down
4 changes: 2 additions & 2 deletions tests/cartPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test.describe("Cart Page Validation", () => {
await expect(page).toHaveURL("https://www.saucedemo.com/cart.html")
const ui= cartPage.getCartPageElements()
await expect((await ui).cartTile).toBeVisible();
expect((await ui).shoppingCart).toBeVisible();
// expect((await ui).shoppingCart).toBeVisible();
expect((await ui).checkOut).toBeVisible();
})
test("Validate Continue Shopping Functionality", async({page})=>
Expand Down Expand Up @@ -67,7 +67,7 @@ test.describe("Cart Page Validation", () => {
const cartProducts = await cartPage.getCartProducts();
expect(cartProducts).toEqual(getSpecificProductDetails);
})
test.only("Validate Remove Product functionality", async({page})=>
test("Validate Remove Product functionality", async({page})=>
{
await productPage.addAllProductsToCart();
await productPage.clickOnCartLink();
Expand Down
2 changes: 1 addition & 1 deletion tests/checkoutOverview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test("Validate Item Total calculation", async({page})=>
const UIItemTotal = await checkoutOverview.getItemTotal();
expect(calculatedTotal).toBe(UIItemTotal)
})
test.only("Validate Final Toal (ItemTotal + Tax)", async({page})=>
test("Validate Final Toal (ItemTotal + Tax)", async({page})=>
{
const itemTotal = await checkoutOverview.getItemTotal();
const tax = await checkoutOverview.getTax();
Expand Down
2 changes: 1 addition & 1 deletion tests/checkoutPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test.describe("Cart Page Validation", () => {
await checkoutPage.fillCheckoutDetail(checckoutData.firstName, checckoutData.lastName, checckoutData.postalCode);
await checkoutPage.clickOnContinue();
})
test.only("Validate the error when clicking on continue with no data", async({page})=>
test("Validate the error when clicking on continue with no data", async({page})=>
{
await cartPage.clickCheckoutButton();
await checkoutPage.clickOnContinue();
Expand Down
2 changes: 1 addition & 1 deletion tests/finalPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test.describe("Final Page Validation", () => {
await expect(elements.pageInfo).toBeVisible()
})

test.only("Validate the Success Message", async({page})=>
test("Validate the Success Message", async({page})=>
{
const message = await finalPage.getSuccessMsgText();
expect(message).toBe("Thank you for your order!")
Expand Down
4 changes: 2 additions & 2 deletions tests/productPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ test.describe("Product Page Validation", () => {
const sorted = [...names].sort().reverse();
expect(names).toEqual(sorted);
})
test.only('Filter By Price Low to High', async () => {
test('Filter By Price Low to High', async () => {
await productPage.filterByPriceLowToHigh();
const prices = await productPage.getProductPrices()
const sortedPrice =[...prices].sort((a,b) => a-b)
expect(prices).toEqual(sortedPrice)
})
test.only('Filter By Price High to Low', async () => {
test('Filter By Price High to Low', async () => {
await productPage.filterByPriceHighToLow()
const prices = await productPage.getProductPrices()
const sortedPrice =[...prices].sort((a,b) => b-a)
Expand Down