Skip to content

Commit f5dbb00

Browse files
2 parents baacd90 + 0082e3c commit f5dbb00

File tree

10 files changed

+135
-23
lines changed

10 files changed

+135
-23
lines changed

.github/workflows/playwright.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Playwright Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
playwright-tests:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 18
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Install Playwright browsers
26+
run: npx playwright install --with-deps
27+
28+
- name: Run Playwright tests
29+
run: npx playwright test

tests/E2E/endTests.spec.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { test, expect} from '@playwright/test'
2+
import { BASE_URL, USERNAME, PASSWORD } from '../../utils/envConfig'
3+
import { ProductPage } from '../../pages/ProductPage'
4+
import { LoginPage } from '../../pages/LoginPage'
5+
import { LoginLocators } from '../../locators/LoginLocators'
6+
import { CartPage } from '../../pages/CartPage'
7+
import { CheckoutPage } from '../../pages/CheckoutPage'
8+
import { checckoutData } from '../../test-data/checkoutData'
9+
import { productsToCart } from '../../test-data/products'
10+
import { CheckoutOverviewPage } from '../../pages/CheckoutOverviewPage'
11+
import { FinalPage } from '../../pages/FinalPage'
12+
13+
14+
test.describe("E2E End Page Validation", () => {
15+
let loginPage: LoginPage
16+
let productPage: ProductPage
17+
let cartPage : CartPage
18+
let checkoutPage : CheckoutPage
19+
let checkoutOverview : CheckoutOverviewPage
20+
let finalPage : FinalPage
21+
22+
test.beforeEach(async ({ page }) => {
23+
loginPage = new LoginPage(page);
24+
productPage = new ProductPage(page);
25+
cartPage = new CartPage(page)
26+
checkoutPage = new CheckoutPage(page)
27+
checkoutOverview = new CheckoutOverviewPage(page)
28+
finalPage = new FinalPage(page);
29+
30+
await page.goto(BASE_URL);
31+
await loginPage.login(USERNAME, PASSWORD);
32+
33+
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html");
34+
35+
await productPage.getSpecificProductDetails(productsToCart);
36+
await productPage.clickOnCartLink();
37+
await cartPage.clickCheckoutButton();
38+
await checkoutPage.fillCheckoutDetail(checckoutData.firstName, checckoutData.lastName, checckoutData.postalCode);
39+
await checkoutPage.clickOnContinue();
40+
await checkoutOverview.clickOnFinish();
41+
})
42+
43+
test("Validate checkout overview page UI and url", async({page})=>
44+
{
45+
await expect(page).toHaveURL("https://www.saucedemo.com/checkout-complete.html")
46+
const elements = await finalPage.getFinalPageElements();
47+
await expect(elements.backHomeBtn).toBeVisible()
48+
await expect(elements.successMsg).toBeVisible()
49+
await expect(elements.pageInfo).toBeVisible()
50+
})
51+
52+
test("Validate the Success Message", async({page})=>
53+
{
54+
const message = await finalPage.getSuccessMsgText();
55+
expect(message).toBe("Thank you for your order!")
56+
})
57+
test ("Validate BackHomeButton", async({page})=>
58+
{
59+
await finalPage.clickOnBackHomeBtn();
60+
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
61+
})
62+
test ("Validate BackHomeButton 1", async({page})=>
63+
{
64+
await finalPage.clickOnBackHomeBtn();
65+
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
66+
})
67+
test ("Validate BackHomeButton 2", async({page})=>
68+
{
69+
await finalPage.clickOnBackHomeBtn();
70+
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
71+
})
72+
test ("Validate BackHomeButton 4", async({page})=>
73+
{
74+
await finalPage.clickOnBackHomeBtn();
75+
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
76+
})
77+
test ("End to Test Validate BackHomeButton 1", async({page})=>
78+
{
79+
await finalPage.clickOnBackHomeBtn();
80+
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
81+
})
82+
83+
})

tests/E2E/finalPage.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CheckoutOverviewPage } from '../../pages/CheckoutOverviewPage'
1111
import { FinalPage } from '../../pages/FinalPage'
1212

1313

14-
test.describe("Final Page Validation", () => {
14+
test.describe("E2E Final Page Validation", () => {
1515
let loginPage: LoginPage
1616
let productPage: ProductPage
1717
let cartPage : CartPage
@@ -30,7 +30,7 @@ test.describe("Final Page Validation", () => {
3030
await page.goto(BASE_URL);
3131
await loginPage.login(USERNAME, PASSWORD);
3232

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

3535
await productPage.getSpecificProductDetails(productsToCart);
3636
await productPage.clickOnCartLink();
@@ -40,7 +40,7 @@ test.describe("Final Page Validation", () => {
4040
await checkoutOverview.clickOnFinish();
4141
})
4242

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

52-
test.only("Validate the Success Message", async({page})=>
52+
test("e2e Validate the Success Message", async({page})=>
5353
{
5454
const message = await finalPage.getSuccessMsgText();
5555
expect(message).toBe("Thank you for your order!")
5656
})
57-
test ("Validate BackHomeButton", async({page})=>
57+
test ("e2e Validate BackHomeButton", async({page})=>
5858
{
5959
await finalPage.clickOnBackHomeBtn();
6060
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
6161
})
62-
test ("Validate BackHomeButton 1", async({page})=>
62+
test ("e2e Validate BackHomeButton 1", async({page})=>
6363
{
6464
await finalPage.clickOnBackHomeBtn();
6565
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
6666
})
67-
test ("Validate BackHomeButton 2", async({page})=>
67+
test (" e2e Validate BackHomeButton 2", async({page})=>
6868
{
6969
await finalPage.clickOnBackHomeBtn();
7070
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
7171
})
72-
test ("Validate BackHomeButton 4", async({page})=>
72+
test ("e2e Validate BackHomeButton 4", async({page})=>
7373
{
7474
await finalPage.clickOnBackHomeBtn();
7575
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
7676
})
77-
test ("Validate BackHomeButton 1", async({page})=>
77+
test ("e2e Validate BackHomeButton 2", async({page})=>
7878
{
7979
await finalPage.clickOnBackHomeBtn();
8080
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")

tests/IntegrationTesting/finalPage.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test.describe("Final Page Validation", () => {
3838
await checkoutOverview.clickOnFinish();
3939
})
4040

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

50-
test.only("Validate the Success Message", async({page})=>
50+
test("int Validate the Success Message", async({page})=>
5151
{
5252
const message = await finalPage.getSuccessMsgText();
5353
expect(message).toBe("Thank you for your order!")
5454
})
55-
test ("Validate BackHomeButton", async({page})=>
55+
test ("Int Validate BackHomeButton", async({page})=>
5656
{
5757
await finalPage.clickOnBackHomeBtn();
5858
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")
5959
})
60-
test ("Validate BackHomeButton 1234", async({page})=>
60+
test ("int Validate BackHomeButton 1234", async({page})=>
6161
{
6262
await finalPage.clickOnBackHomeBtn();
6363
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")

tests/Smoke/finalPage.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test.describe("Final Page Validation", () => {
3838
await checkoutOverview.clickOnFinish();
3939
})
4040

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

50-
test.only("Validate the Success Message", async({page})=>
50+
test("smo Validate the Success Message", async({page})=>
5151
{
5252
const message = await finalPage.getSuccessMsgText();
5353
expect(message).toBe("Thank you for your order!")
5454
})
55-
test ("Validate BackHomeButton", async({page})=>
55+
test ("smoke Validate BackHomeButton", async({page})=>
5656
{
5757
await finalPage.clickOnBackHomeBtn();
5858
await expect(page).toHaveURL("https://www.saucedemo.com/inventory.html")

tests/cartPage.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test.describe("Cart Page Validation", () => {
3030
await expect(page).toHaveURL("https://www.saucedemo.com/cart.html")
3131
const ui= cartPage.getCartPageElements()
3232
await expect((await ui).cartTile).toBeVisible();
33-
expect((await ui).shoppingCart).toBeVisible();
33+
// expect((await ui).shoppingCart).toBeVisible();
3434
expect((await ui).checkOut).toBeVisible();
3535
})
3636
test("Validate Continue Shopping Functionality", async({page})=>
@@ -67,7 +67,7 @@ test.describe("Cart Page Validation", () => {
6767
const cartProducts = await cartPage.getCartProducts();
6868
expect(cartProducts).toEqual(getSpecificProductDetails);
6969
})
70-
test.only("Validate Remove Product functionality", async({page})=>
70+
test("Validate Remove Product functionality", async({page})=>
7171
{
7272
await productPage.addAllProductsToCart();
7373
await productPage.clickOnCartLink();

tests/checkoutOverview.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ test("Validate Item Total calculation", async({page})=>
5757
const UIItemTotal = await checkoutOverview.getItemTotal();
5858
expect(calculatedTotal).toBe(UIItemTotal)
5959
})
60-
test.only("Validate Final Toal (ItemTotal + Tax)", async({page})=>
60+
test("Validate Final Toal (ItemTotal + Tax)", async({page})=>
6161
{
6262
const itemTotal = await checkoutOverview.getItemTotal();
6363
const tax = await checkoutOverview.getTax();

tests/checkoutPage.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test.describe("Cart Page Validation", () => {
4848
await checkoutPage.fillCheckoutDetail(checckoutData.firstName, checckoutData.lastName, checckoutData.postalCode);
4949
await checkoutPage.clickOnContinue();
5050
})
51-
test.only("Validate the error when clicking on continue with no data", async({page})=>
51+
test("Validate the error when clicking on continue with no data", async({page})=>
5252
{
5353
await cartPage.clickCheckoutButton();
5454
await checkoutPage.clickOnContinue();

tests/finalPage.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test.describe("Final Page Validation", () => {
4747
await expect(elements.pageInfo).toBeVisible()
4848
})
4949

50-
test.only("Validate the Success Message", async({page})=>
50+
test("Validate the Success Message", async({page})=>
5151
{
5252
const message = await finalPage.getSuccessMsgText();
5353
expect(message).toBe("Thank you for your order!")

tests/productPage.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ test.describe("Product Page Validation", () => {
5555
const sorted = [...names].sort().reverse();
5656
expect(names).toEqual(sorted);
5757
})
58-
test.only('Filter By Price Low to High', async () => {
58+
test('Filter By Price Low to High', async () => {
5959
await productPage.filterByPriceLowToHigh();
6060
const prices = await productPage.getProductPrices()
6161
const sortedPrice =[...prices].sort((a,b) => a-b)
6262
expect(prices).toEqual(sortedPrice)
6363
})
64-
test.only('Filter By Price High to Low', async () => {
64+
test('Filter By Price High to Low', async () => {
6565
await productPage.filterByPriceHighToLow()
6666
const prices = await productPage.getProductPrices()
6767
const sortedPrice =[...prices].sort((a,b) => b-a)

0 commit comments

Comments
 (0)