From a2bbf1e39c96a1083ffbbdfd8b7136a6975cca22 Mon Sep 17 00:00:00 2001 From: najeeb1023 Date: Wed, 26 Jun 2024 16:41:40 +0200 Subject: [PATCH 1/3] select random product refactored --- src/test/features/UserShoppingByWear.feature | 4 +- src/test/pages/UserShoppingByWear.ts | 45 +++++++++++--------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/test/features/UserShoppingByWear.feature b/src/test/features/UserShoppingByWear.feature index 242d6ad..ed1a3a3 100644 --- a/src/test/features/UserShoppingByWear.feature +++ b/src/test/features/UserShoppingByWear.feature @@ -14,8 +14,8 @@ Feature: Verify that the user is able to purchase some item. And The details of the product are shown. Examples: - | Section | Attire | - | Men | Shorts | + | Section | Attire | + | Men | Jackets | @WomenShopping Scenario: User shops for Women Jackets. diff --git a/src/test/pages/UserShoppingByWear.ts b/src/test/pages/UserShoppingByWear.ts index 4ba791c..e3b90e5 100644 --- a/src/test/pages/UserShoppingByWear.ts +++ b/src/test/pages/UserShoppingByWear.ts @@ -84,29 +84,32 @@ import { Page, expect } from "@playwright/test"; }; public async selectRandomProduct():Promise{ - const getNumberOfProducts = await this.userShoppingByWearByWearLocators.productShown().count(); - let ind: number = Math.floor(Math.random() * (getNumberOfProducts - 1))+ 1; - if (ind == 0) { - Math.floor(Math.random() * getNumberOfProducts); - } else { - const el = (pageFixture.page.locator(getResource('itemsShown').selectorValue.replace('FLAG', `${ind}`))); - await expect(el).toBeVisible(); - await el.dblclick({force: true, timeout: 3000}); - const list = await this.userShoppingByWearByWearLocators.shoppingList().isVisible(); - const listCount = await this.userShoppingByWearByWearLocators.shoppingList().count(); - if (list == true){ - await pageFixture.logger.warn('User not navigated, retrying click'); - await pageFixture.page.waitForLoadState('networkidle'); - for(let i=0;i{ From 29824eaa0ecb19c78bc6eab2304fcd38bf8c93ec Mon Sep 17 00:00:00 2001 From: najeeb1023 Date: Wed, 26 Jun 2024 17:06:22 +0200 Subject: [PATCH 2/3] version updated --- .github/workflows/release.yaml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index caad08e..c23acab 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: v3.4.2. +name: v3.5.1. on: push diff --git a/README.md b/README.md index a8b5a11..1c122a2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Magento WebApp Test Automation Framework -[![v3.4.2.](https://github.com/najeeb1023/magento-webapp/actions/workflows/release.yaml/badge.svg)](https://github.com/najeeb1023/magento-webapp/actions/workflows/release.yaml) +[![v3.5.1.](https://github.com/najeeb1023/magento-webapp/actions/workflows/release.yaml/badge.svg)](https://github.com/najeeb1023/magento-webapp/actions/workflows/release.yaml) ![License](https://img.shields.io/badge/license-MIT-green) ## Overview From 82dc456e699e99416c5adc71ac06bbc38b1b41fe Mon Sep 17 00:00:00 2001 From: najeeb1023 Date: Thu, 27 Jun 2024 20:29:30 +0200 Subject: [PATCH 3/3] click add to cart button added. --- .github/workflows/release.yaml | 2 +- src/test/features/ShopBySearch.feature | 4 ++-- src/test/pages/ShopBySearch.ts | 11 ++++++++--- src/test/resources/shopBySearchPage.json | 4 ++++ src/test/steps/shopBySearch.ts | 3 ++- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c23acab..fb7fa28 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: v3.5.1. +name: v3.5.1 on: push diff --git a/src/test/features/ShopBySearch.feature b/src/test/features/ShopBySearch.feature index 7653e6f..e7e191c 100644 --- a/src/test/features/ShopBySearch.feature +++ b/src/test/features/ShopBySearch.feature @@ -10,8 +10,8 @@ Feature: Verify that the user is able to purchase an item by searching. Scenario: User navigates to any random product to get its title. When The user clicks on the "
" section and the user clicks on "" option. And The products are shown and user navigates to a product. - And User searches that product. + And User searches that product, going to the cart. Examples: | Section | Attire | - | Men | Shorts | \ No newline at end of file + | Men | Shorts | \ No newline at end of file diff --git a/src/test/pages/ShopBySearch.ts b/src/test/pages/ShopBySearch.ts index c1c7d50..1eafc95 100644 --- a/src/test/pages/ShopBySearch.ts +++ b/src/test/pages/ShopBySearch.ts @@ -11,13 +11,18 @@ import { pageFixture } from "../hooks/pageFixture"; shopBySearchLocators = { lumaLogo:() => pageFixture.page.locator(getResource('lumaLogo').selectorValue), - searchBar:() => pageFixture.page.locator(getResource('searchBar').selectorValue) + searchBar:() => pageFixture.page.locator(getResource('searchBar').selectorValue), + addToCartBtn:() => pageFixture.page.locator(getResource('goToCartBtn').selectorValue) }; - public async searchProduct():Promise{ + public async searchProduct():Promise { console.log('Selected product:', UserShoppingByWear.globalArray[0]); await this.shopBySearchLocators.searchBar().fill(UserShoppingByWear.globalArray[0]); await pageFixture.page.keyboard.press('Enter'); }; - }; \ No newline at end of file + + public async checkOutToCart():Promise { + await this.shopBySearchLocators.addToCartBtn().click(); + }; +}; \ No newline at end of file diff --git a/src/test/resources/shopBySearchPage.json b/src/test/resources/shopBySearchPage.json index f762236..6f01525 100644 --- a/src/test/resources/shopBySearchPage.json +++ b/src/test/resources/shopBySearchPage.json @@ -8,6 +8,10 @@ { "elementName": "searchBar", "selectorValue": "//div[contains(@class,'field search')]//input" + }, + { + "elementName": "goToCartBtn", + "selectorValue": "//div[contains(@class, 'minicart')]//span[contains(.,'My Cart')]" } ] } diff --git a/src/test/steps/shopBySearch.ts b/src/test/steps/shopBySearch.ts index 5e45c26..15464e9 100644 --- a/src/test/steps/shopBySearch.ts +++ b/src/test/steps/shopBySearch.ts @@ -5,6 +5,7 @@ import { pageFixture } from "../hooks/pageFixture"; setDefaultTimeout(60000); let shopBySearch = new ShopBySearch(pageFixture.page); -When('User searches that product.', async function (){ +When('User searches that product, going to the cart.', async function (){ await shopBySearch.searchProduct(); + await shopBySearch.checkOutToCart(); }); \ No newline at end of file