Skip to content

הוספת לוגין רמי לוי ופונקציונליות חיפוש והוספת מוצר לעגלה בשופרסל - #3

Open
ChayaEinhoren wants to merge 1 commit into
exercisesfrom
ChayaEinhoren
Open

הוספת לוגין רמי לוי ופונקציונליות חיפוש והוספת מוצר לעגלה בשופרסל#3
ChayaEinhoren wants to merge 1 commit into
exercisesfrom
ChayaEinhoren

Conversation

@ChayaEinhoren

Copy link
Copy Markdown
Collaborator

ב־PR זה נוספו השינויים הבאים:

*מימוש תהליך התחברות (Login) לאתר רמי לוי. ברמי לוי, רוב הפונקציונליות רצה תקין, אך קיימת שגיאה הקשורה לסינון. שלחתי פניה לנטפריי וממתינה לתגובה.

*מימוש פונקציונליות חיפוש מוצר והוספת מוצר לעגלת הקניות באתר שופרסל. הפונקציונליות עובדת, אך הקוד בשלב זה אינו מסודר לפי פונקציות של base_store. בעז"ה אני מטפלת בזה היום בערב.

תיקונים ושיפורים כלליים בקוד הקשור לסקרייפרים ולניהול החנויות.

אשמח לסקירה ואישור.

Comment thread core/base_store.py

class BaseStore(OnlineStore):

# ✅ פונקציית login - מרוכזת אחת בלבד

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

תעוד לקוד אמור להיות בעברית

Comment thread core/base_store.py

self.wait_and_click(self.get_submit_selector())

# self.wait_until_disappear(self.get_username_selector())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

האם מדובר בלוגין לאתר מסוים או לוגין כללי?
כי אם מדובר בלוגין כללי div#user-box מתכוון לID ספציפי, ואם מדובר בלוגין ספציפי - למה הוא ממומש בקלאס הזה?

Comment thread core/base_store.py
pass

# ✅ פונקציות עזר כלליות לשימוש חוזר בכל תהליך (לא רק login)
def wait_for_element(self, selector, timeout=10):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

הפונקציות הכלליות מצוינות.
הייתי ממליצה להפריד אותן לclass אחר סטטי (יקראו לו לדוגמא SeleniumAction)

Comment thread core/online_store.py
@@ -0,0 +1,70 @@
class OnlineStore:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

מדובר בabstract class, תוסיפי לשם של הclass ירושה בABC
ובכל הפונקציות תכתבי pass במקום raise NotImplementedError

Comment thread stores/shufersal_store.py

class ShufersalStore(OnlineStore):
def login(self, username, password):
try:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

תשמרי את הURL כמשתנה מחלקה קבוע

class ShufersalStore(OnlineStore):
    URL = "https://www.shufersal.co.il/"

Comment thread stores/shufersal_store.py

def search_item(self, item_name):
print(f"מחפש: {item_name}")
self.driver.get("https://www.shufersal.co.il/")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

אנחנו צריכות לשוחח על שינוי במבנה שיעזור לנו לא לטעון את הדף בכל פונקציה מחדש (אם את מעוניינת לנסות לבד תקראי על POM) בקצרה: כשאת עובדת עם סלניום ב-OOP, את לא צריכה לטעון את האתר מחדש בכל פונקציה. הגישה הנכונה היא להשתמש ב-Page Object Model (POM): כל עמוד באתר מיוצג על ידי מחלקה נפרדת שמכילה את האלמנטים והפעולות הרלוונטיות, והדרייבר מועבר ביניהן, מה שהופך את הקוד ליעיל וקל לתחזוקה.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants