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
24 changes: 10 additions & 14 deletions actions/ShopbycategoryAction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import os

from pages.ShopbyCategoryPage import ShopByCategoryPage
from utils.loggerCreator import get_logger
Expand All @@ -14,37 +15,33 @@ def __init__(self, driver):
self.wait = WebDriverWait(driver, 20)

def launch_url(self, url):

try:
logger.info(f"Launching URL: {url}")
self.driver.get(url)
self.driver.maximize_window()

is_headless = os.getenv("CI", "").lower() == "true"
if not is_headless:
self.driver.maximize_window()

logger.info("Application launched successfully")

except Exception as e:
logger.error( f"Failed to launch application: {e}")
logger.error(f"Failed to launch application: {e}")
raise

def click_shop_by_category(self):

try:
logger.info("Clicking Shop By Category menu")
element = self.wait.until(
EC.element_to_be_clickable(
self.page.SHOP_BY_CATEGORY_MENU
)
)

element.click()
element = self.wait.until(EC.presence_of_element_located(self.page.SHOP_BY_CATEGORY_MENU))
self.driver.execute_script("arguments[0].scrollIntoView(true);", element)
self.driver.execute_script("arguments[0].click();", element)
logger.info("Successfully clicked Shop By Category menu")

except Exception as e:
logger.error(f"Unable to click Shop By Category menu: {e}")
raise

def select_category(self, category):

try:
logger.info(f"Selecting category: {category}")

Expand Down Expand Up @@ -73,10 +70,9 @@ def select_category(self, category):
raise

def get_page_title(self):

try:
title = self.driver.title
logger.info( f"Page title fetched successfully: {title}")
logger.info(f"Page title fetched successfully: {title}")
return title
except Exception as e:
logger.error(f"Unable to fetch page title: {e}")
Expand Down
4 changes: 3 additions & 1 deletion configuration/config.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[browser]
browser = firefox
browser = chrome
mode = headless

mode = normal

[application]
url = https://ecommerce-playground.lambdatest.io/index.php?route=common/home
title = Your Store
Expand Down
2 changes: 1 addition & 1 deletion pages/ShopbyCategoryPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ShopByCategoryPage:

SHOP_BY_CATEGORY_MENU = (By.XPATH, "//a[contains(.,'Shop by Category')]")
SHOP_BY_CATEGORY_MENU = (By.XPATH, "//button[contains(.,'Shop by Category')] | //a[contains(.,'Shop by Category')]")
DESKTOPS_CATEGORY = (By.XPATH, "//span[@class='title' and normalize-space()='Desktops and Monitors']")
CAMERAS = (By.LINK_TEXT, "Web Cameras")
TABLETS = (By.LINK_TEXT, "Phone, Tablets & Ipod")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def test_register_checkout(self, driver):


action.select_register_account()
data = get_registration_data("D:\Pytest_Automation_Project\data_provider\DataProvider.xlsx", "Registration")

data = get_registration_data(r"D:\Pytest_Automation_Project\data_provider\DataProvider.xlsx", "Registration")

action.enter_registration_details(data)
action.agree_to_privacy_policy()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_shopbycategory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

logger = get_logger(__name__)

@pytest.mark.ShopByCategory
@pytest.mark.Samiha
class TestShopByCategory:

@pytest.mark.parametrize(
Expand All @@ -25,4 +25,4 @@ def test_category_navigation(self, driver, category, expected_title):
action.select_category(category)
actual_title = action.get_page_title()

assert expected_title in actual_title
assert expected_title in actual_title
Loading