From 24a2df679ae6f7e3835879802a7aabbb4f48a61f Mon Sep 17 00:00:00 2001 From: win Date: Sun, 14 Jun 2026 12:01:21 +0530 Subject: [PATCH 1/3] added the test_blog file --- tests/test_blog.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/test_blog.py b/tests/test_blog.py index e69de29..fbf2fa1 100644 --- a/tests/test_blog.py +++ b/tests/test_blog.py @@ -0,0 +1,62 @@ +import pytest + +from actions.blogAction import BlogAction +from utils.configReader import ConfigReader + + +@pytest.mark.Samiha +class TestBlog: + + def test_blog_menu(self, driver): + + drv, wait = driver + action = BlogAction(drv) + drv.get(ConfigReader.get_url()) + action.click_blog_menu() + + assert action.is_latest_article_visible() + + def test_first_article(self, driver): + + drv, wait = driver + action = BlogAction(drv) + drv.get(ConfigReader.get_url()) + action.click_blog_menu() + action.open_first_article() + + assert action.is_article_visible() + + @pytest.mark.parametrize( + "category", + [ + "business", + "electronics", + "technology", + "fashion" + ] + ) + def test_blog_comment(self, driver, category): + + drv, wait = driver + action = BlogAction(drv) + + drv.get(ConfigReader.get_url()) + action.click_blog_menu() + + if category == "business": + action.click_business_category() + elif category == "electronics": + action.click_electronics_category() + elif category == "technology": + action.click_technology_category() + else: + action.click_fashion_category() + action.open_first_article() + + action.post_comment( + name="Samiha", + email="samiha@test.com", + comment=f"Automation comment for {category}" + ) + + assert action.is_comment_posted() From 617678f2424341318c6e25ae3f36d83fb2aef908 Mon Sep 17 00:00:00 2001 From: win Date: Sun, 14 Jun 2026 12:09:23 +0530 Subject: [PATCH 2/3] added the blogaction file --- actions/blogAction.py | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/actions/blogAction.py b/actions/blogAction.py index e69de29..7aac287 100644 --- a/actions/blogAction.py +++ b/actions/blogAction.py @@ -0,0 +1,57 @@ +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC + +from actions.BaseAction import BaseAction +from pages.blogPage import BlogPage + + +class BlogAction(BaseAction): + + def __init__(self, driver): + super().__init__(driver) + self.bp = BlogPage() + + def js_click(self, locator): + element = WebDriverWait(self.driver, 20).until(EC.presence_of_element_located(locator)) + self.driver.execute_script("arguments[0].scrollIntoView({block: 'center'});", element) + self.driver.execute_script("arguments[0].click();", element) + + def click_blog_menu(self): + self.driver.get("https://ecommerce-playground.lambdatest.io""/index.php?route=extension/maza/blog/home") + + def is_latest_article_visible(self): + return self.is_displayed(self.bp.LATEST_ARTICLE_SECTION) + + def click_business_category(self): + self.js_click(self.bp.BUSINESS_CATEGORY) + + def click_electronics_category(self): + self.js_click(self.bp.ELECTRONICS_CATEGORY) + + def click_technology_category(self): + self.js_click(self.bp.TECHNOLOGY_CATEGORY) + + def click_fashion_category(self): + self.js_click(self.bp.FASHION_CATEGORY) + + def open_first_article(self): + self.js_click(self.bp.FIRST_ARTICLE) + + WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located(self.bp.ARTICLE_TITLE)) + def is_article_visible(self): + return self.is_displayed(self.bp.ARTICLE_TITLE) + + def post_comment(self, name, email, comment): + + self.scroll_into_view(self.bp.COMMENT_NAME) + self.send_keys(self.bp.COMMENT_NAME, name) + self.send_keys(self.bp.COMMENT_EMAIL, email) + self.send_keys(self.bp.COMMENT_TEXT, comment) + self.js_click(self.bp.POST_COMMENT_BUTTON) + + def is_comment_posted(self): + try: + self.wait.until(EC.visibility_of_element_located(self.bp.COMMENT_SUCCESS)) + return True + except Exception: + return False From 0183825df5a9efb4d91e613f8aa1b76cb5aff163 Mon Sep 17 00:00:00 2001 From: win Date: Sun, 14 Jun 2026 12:51:26 +0530 Subject: [PATCH 3/3] Enhanced checkout file --- actions/checkoutAction.py | 66 ++++-------------------------- data_provider/~$DataProvider.xlsx | Bin 0 -> 165 bytes pages/checkoutPage.py | 7 ---- tests/test_checkout.py | 37 +++-------------- 4 files changed, 13 insertions(+), 97 deletions(-) create mode 100644 data_provider/~$DataProvider.xlsx diff --git a/actions/checkoutAction.py b/actions/checkoutAction.py index 6738e3c..27e6591 100644 --- a/actions/checkoutAction.py +++ b/actions/checkoutAction.py @@ -16,10 +16,6 @@ def __init__(self, driver): self.hp=HomePage(driver) self.pp=ProductPage(driver) - # ========================= - # PRODUCT FLOW - # ========================= - def click_hp_product(self): self.click(self.hp.Hp_Product) @@ -32,9 +28,6 @@ def click_shopping_cart_from_popup(self): def click_checkout_from_cart_page(self): self.click(self.cp.CART_PAGE_CHECKOUT_BTN) - # ========================= - # LOGIN FLOW - # ========================= def click_Login_Radio(self): self.click(self.cp.LOGIN_RADIO) @@ -46,20 +39,11 @@ def login_from_checkout_page(self, email=None, password=None): self.send_keys(self.cp.LOGIN_EMAIL, email) self.send_keys(self.cp.LOGIN_PASSWORD, password) - login_btn = WebDriverWait(self.driver, 20).until( - EC.element_to_be_clickable(self.cp.LOGIN_BUTTON) - ) - + login_btn = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable(self.cp.LOGIN_BUTTON)) self.driver.execute_script("arguments[0].scrollIntoView(true);", login_btn) login_btn.click() - WebDriverWait(self.driver, 20).until( - EC.visibility_of_element_located(self.cp.FIRST_NAME_INPUT) - ) - - # ========================= - # BILLING DETAILS - # ========================= + WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located(self.cp.FIRST_NAME_INPUT)) def enter_billing_details(self, data=None): @@ -82,54 +66,30 @@ def enter_billing_details(self, data=None): def click_same_billing_address(self): self.click(self.cp.SAME_BILLING_ADDRESS_LABEL) - # ========================= - # SHIPPING - # ========================= - def select_flat_rate(self): - flat_rate = WebDriverWait(self.driver, 20).until( - EC.element_to_be_clickable(self.cp.FLAT_RATE_LABEL) - ) - + flat_rate = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable(self.cp.FLAT_RATE_LABEL)) self.driver.execute_script("arguments[0].scrollIntoView(true);", flat_rate) self.driver.execute_script("arguments[0].click();", flat_rate) - # ========================= - # PAYMENT - # ========================= - def select_cash_on_delivery(self): - cod = WebDriverWait(self.driver, 20).until( - EC.element_to_be_clickable(self.cp.COD_LABEL) - ) - + cod = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable(self.cp.COD_LABEL)) self.driver.execute_script("arguments[0].scrollIntoView(true);", cod) self.driver.execute_script("arguments[0].click();", cod) def click_terms_and_conditions(self): - terms = WebDriverWait(self.driver, 20).until( - EC.element_to_be_clickable(self.cp.TERMS_LABEL) - ) - + terms = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable(self.cp.TERMS_LABEL)) self.driver.execute_script("arguments[0].scrollIntoView(true);", terms) self.driver.execute_script("arguments[0].click();", terms) def continue_checkout(self): - btn = WebDriverWait(self.driver, 20).until( - EC.element_to_be_clickable(self.cp.CONTINUE_CHECKOUT_BTN) - ) - + btn = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable(self.cp.CONTINUE_CHECKOUT_BTN)) self.driver.execute_script("arguments[0].scrollIntoView(true);", btn) self.driver.execute_script("arguments[0].click();", btn) - # ========================= - # REGISTER FLOW - # ========================= - def select_register_account(self): self.click(self.cp.REGISTER_ACCOUNT_RADIO) @@ -144,28 +104,18 @@ def enter_registration_details(self, data): def agree_to_privacy_policy(self): - privacy = WebDriverWait(self.driver, 20).until( - EC.element_to_be_clickable(self.cp.PRIVACY_LABEL) - ) - + privacy = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable(self.cp.PRIVACY_LABEL)) self.driver.execute_script("arguments[0].scrollIntoView(true);", privacy) self.driver.execute_script("arguments[0].click();", privacy) def agree_to_account_privacy_policy(self): - privacy = WebDriverWait(self.driver, 20).until( - EC.element_to_be_clickable(self.cp.ACCOUNT_PRIVACY_LABEL) - ) - + privacy = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable(self.cp.ACCOUNT_PRIVACY_LABEL)) self.driver.execute_script("arguments[0].scrollIntoView(true);", privacy) self.driver.execute_script("arguments[0].click();", privacy) - # ========================= - # VALIDATIONS - # ========================= def clickContinueCheckout(self): self.click(self.cp.CONTINUE_CHECKOUT_BTN) def is_order_placed_successfully(self): return self.is_displayed(self.cp.ORDER_CONFIRMATION_MSG) - def is_empty_cart_message_displayed(self): return self.is_displayed(self.cp.EMPTY_CART_MESSAGE) \ No newline at end of file diff --git a/data_provider/~$DataProvider.xlsx b/data_provider/~$DataProvider.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..0d6a890a4a13c3b676d12a2fc7f1fdc273e37cb6 GIT binary patch literal 165 ZcmZQB&&*RG9WXPLGh{O4F(}Xl0ss-o4`ToT literal 0 HcmV?d00001 diff --git a/pages/checkoutPage.py b/pages/checkoutPage.py index 1463501..c8e9630 100644 --- a/pages/checkoutPage.py +++ b/pages/checkoutPage.py @@ -2,19 +2,16 @@ class CheckoutPage: - # -------- Product -------- HP_PRODUCT_IMAGE = (By.XPATH, "//img[@title='HP LP3065']") ADD_TO_CART_BTN = (By.XPATH, "//button[contains(@id,'button-cart')]") SHOPPING_CART_POPUP_LINK = (By.XPATH, "//a[contains(text(),'shopping cart')]") CART_PAGE_CHECKOUT_BTN = (By.XPATH, "//a[text()='Checkout']") - # -------- Login -------- LOGIN_RADIO = (By.XPATH, "//label[@for='input-account-login']") LOGIN_EMAIL = (By.ID, "input-login-email") LOGIN_PASSWORD = (By.ID, "input-login-password") LOGIN_BUTTON = (By.XPATH, "//button[contains(text(),'Login')]") - # -------- Register -------- REGISTER_ACCOUNT_RADIO = (By.XPATH, "//label[@for='input-account-register']") PRIVACY_LABEL = (By.XPATH, "//label[@for='input-agree']") @@ -25,23 +22,19 @@ class CheckoutPage: REG_PASSWORD_INPUT = (By.ID, "input-payment-password") REG_CONFIRM_PASSWORD_INPUT = (By.ID, "input-payment-confirm") - # -------- Billing -------- FIRST_NAME_INPUT = (By.ID, "input-payment-firstname") LAST_NAME_INPUT = (By.ID, "input-payment-lastname") COMPANY_INPUT = (By.ID, "input-payment-company") ADDRESS1_INPUT = (By.ID, "input-payment-address-1") CITY_INPUT = (By.ID, "input-payment-city") POSTCODE_INPUT = (By.ID, "input-payment-postcode") - SAME_BILLING_ADDRESS_LABEL = (By.XPATH, "//label[@for='input-shipping-address-same']") - # -------- Shipping / Payment -------- FLAT_RATE_LABEL = (By.XPATH, "//label[@for='input-shipping-method-flat.flat']") COD_LABEL = (By.XPATH, "//label[@for='input-payment-method-cod']") TERMS_LABEL = (By.XPATH, "//label[@for='input-agree']") CONTINUE_CHECKOUT_BTN = (By.XPATH, "//button[@id='button-save']") ACCOUNT_PRIVACY_LABEL = (By.XPATH, "//label[@for='input-account-agree']") - # -------- Assertions -------- ORDER_CONFIRMATION_MSG = (By.XPATH, "//h1[contains(text(),'Your order has been placed')]") EMPTY_CART_MESSAGE = (By.XPATH, "//div[@id='content']//p") \ No newline at end of file diff --git a/tests/test_checkout.py b/tests/test_checkout.py index b30c545..6d23631 100644 --- a/tests/test_checkout.py +++ b/tests/test_checkout.py @@ -1,18 +1,13 @@ import time - import pytest from actions.checkoutAction import CheckoutAction from utils.configReader import ConfigReader from utils.excelReader import get_registration_data - @pytest.mark.Samiha class TestCheckout: - # ========================= - # 1. LOGIN CHECKOUT - # ========================= def test_login_checkout(self, driver): drv, wait = driver @@ -25,14 +20,9 @@ def test_login_checkout(self, driver): action.click_shopping_cart_from_popup() action.click_checkout_from_cart_page() - # Login step action.click_Login_Radio() - action.login_from_checkout_page( - ConfigReader.get("credentials", "email"), - ConfigReader.get("credentials", "password") - ) - - # Billing details + action.login_from_checkout_page(ConfigReader.get("credentials", "email"),ConfigReader.get("credentials", "password")) + action.enter_billing_details({ "firstname": ConfigReader.get("billing", "first_name"), "lastname": ConfigReader.get("billing", "last_name"), @@ -41,16 +31,11 @@ def test_login_checkout(self, driver): "city": ConfigReader.get("billing", "city"), "postcode": ConfigReader.get("billing", "postcode"), }) - - # Payment + confirm + action.agree_to_privacy_policy() action.clickContinueCheckout() print(action.is_order_placed_successfully()) - - # ========================= - # 2. REGISTER CHECKOUT - # ========================= def test_register_checkout(self, driver): drv, wait = driver @@ -64,11 +49,7 @@ def test_register_checkout(self, driver): action.select_register_account() - - data = get_registration_data( - "E:\Pytest_Automation\data_provider\DataProvider.xlsx", - "Registration" - ) + data = get_registration_data("D:\Pytest_Automation_Project\data_provider\DataProvider.xlsx", "Registration") action.enter_registration_details(data) action.agree_to_privacy_policy() @@ -76,17 +57,9 @@ def test_register_checkout(self, driver): action.clickContinueCheckout() print(action.is_order_placed_successfully()) - - # ========================= - # 3. EMPTY CART CHECKOUT - # ========================= def test_empty_cart_checkout(self, driver): - drv, wait = driver action = CheckoutAction(drv) - drv.get( - "https://ecommerce-playground.lambdatest.io/index.php?route=checkout/cart" - ) - + drv.get("https://ecommerce-playground.lambdatest.io/index.php?route=checkout/cart") print(action.is_empty_cart_message_displayed()) \ No newline at end of file