CP_AUTOMATION/CognitivePrism/my-project/backup_docs/TEMPORARY_LOCATORS_TO_REPLACE.md
2025-12-12 19:54:54 +05:30

5.4 KiB

Temporary Locators to Replace with data-testid

Overview

This document lists ALL temporary locators (XPath, CSS classes, text-based) that need to be replaced with proper data-testid attributes.


🔴 TEMPORARY LOCATORS BY PAGE

1. LOGIN PAGE (pages/login_page.py)

Line 26: Error Toast Notification

Current (Temporary):

ERROR_TOAST = (By.XPATH, "//div[@role='status' and @aria-live='polite' and (contains(text(), 'Invalid') or contains(text(), 'User not found') or contains(text(), 'not found'))]")

Required data-testid:

ERROR_TOAST = (By.CSS_SELECTOR, "[data-testid='student_login__error_toast']")

Usage: Used in is_error_visible() and get_error_message() methods

Priority: ⚠️ Medium (fallback exists)


2. DASHBOARD PAGE (pages/dashboard_page.py)

Line 19: Welcome Message

Current (Temporary):

WELCOME_MESSAGE = (By.XPATH, "//h1[contains(text(), 'Hi There!')]")

Required data-testid:

WELCOME_MESSAGE = (By.CSS_SELECTOR, "[data-testid='dashboard__welcome_message']")

Usage: Currently not actively used, but defined for future use

Priority: ⚠️ Low (not critical)


3. PROFILE EDITOR PAGE (pages/profile_editor_page.py)

Line 328: Tab Scroll Right Button (Primary)

Current (Temporary):

button_locator = (By.XPATH, "//button[contains(@class, 'absolute right-0') and contains(@class, 'z-20')]")

Required data-testid:

TABS_SCROLL_RIGHT_BUTTON = (By.CSS_SELECTOR, "[data-testid='profile_editor__tabs_scroll_right_button']")

Usage: Used in scroll_tabs_right() method

Priority: High (required for tab navigation)

w---

Line 342: Tab Scroll Right Button (Alternative)

Current (Temporary):

button = self.driver.find_element(By.XPATH, "//button[.//*[contains(@class, 'lucide-chevron-right') or contains(@class, 'chevron-right')]]")

Required data-testid: Same as above - profile_editor__tabs_scroll_right_button

Usage: Fallback locator in scroll_tabs_right() method

Priority: High (fallback for primary locator)


Line 360: Tab Scroll Left Button

Current (Temporary):

button = self.wait.wait_for_element_clickable((By.XPATH, "//button[contains(@class, 'absolute left-0') and contains(@class, 'z-20')]"))

Required data-testid:

TABS_SCROLL_LEFT_BUTTON = (By.CSS_SELECTOR, "[data-testid='profile_editor__tabs_scroll_left_button']")

Usage: Used in scroll_tabs_left() method

Priority: High (required for tab navigation)


Line 520: Toast Message Container

Current (Temporary):

EC.presence_of_element_located((By.XPATH, "//div[@role='status']"))

Required data-testid:

TOAST_MESSAGE = (By.CSS_SELECTOR, "[data-testid='profile_editor__toast_message']")
# OR separate for success/error:
SUCCESS_TOAST = (By.CSS_SELECTOR, "[data-testid='profile_editor__success_toast']")
ERROR_TOAST = (By.CSS_SELECTOR, "[data-testid='profile_editor__error_toast']")

Usage: Used in click_save() method to detect success/error messages

Priority: High (required for save verification)


📊 SUMMARY

Total Temporary Locators: 6

Page Count Priority
Login Page 1 Medium
Dashboard Page 1 Low
Profile Editor Page 4 High

Required data-testid Attributes:

  1. student_login__error_toast
  2. dashboard__welcome_message
  3. profile_editor__tabs_scroll_right_button
  4. profile_editor__tabs_scroll_left_button
  5. profile_editor__toast_message (or separate success/error)

🎯 IMPLEMENTATION PRIORITY

Priority 1: CRITICAL (Must Replace)

  1. profile_editor__tabs_scroll_right_button - Required for tab navigation
  2. profile_editor__tabs_scroll_left_button - Required for tab navigation
  3. profile_editor__toast_message - Required for save verification

Priority 2: IMPORTANT (Should Replace)

  1. ⚠️ student_login__error_toast - Improves error detection reliability

Priority 3: NICE TO HAVE (Optional)

  1. ⚠️ dashboard__welcome_message - Not actively used

📝 CODE LOCATIONS FOR UI DEV TEAM

Tab Scroll Buttons

File: src/pages/StudentProfileEditor.jsx Location: Around lines 1850-1860 (tab scroll container)

Required:

<button
  onClick={() => scrollTabs('right')}
  data-testid="profile_editor__tabs_scroll_right_button"
  ...
>
  <ChevronRight ... />
</button>

<button
  onClick={() => scrollTabs('left')}
  data-testid="profile_editor__tabs_scroll_left_button"
  ...
>
  <ChevronLeft ... />
</button>

Toast Messages

File: Toast notification component (likely in a shared component) Location: Where toast notifications are rendered

Required:

<div
  role="status"
  aria-live="polite"
  data-testid="profile_editor__toast_message"
  // OR separate:
  data-testid="profile_editor__success_toast" // for success
  data-testid="profile_editor__error_toast"   // for errors
  ...
>

Login Error Toast

File: Login page component Location: Where error toast is rendered

Required:

<div
  role="status"
  aria-live="polite"
  data-testid="student_login__error_toast"
  ...
>

Document Version: 1.0 Status: Ready for UI Dev Team Implementation