Posts

Showing posts with the label Design Pattern

תבניות עיצוב - מפעל

Image
תבניות עיצוב  ״ הי-יו ג׳ורד ת׳יודע מה חזק ?    קוד שמתכנת לממשק ולא למימוש זה חזק ! ״ אנחנו רוצים שהקוד שלנו יהיה גנרי ומאפשר התפתחות עתידית, כדי שאם נרצה להוסיף אובייקטים שונים, לא נצטרך לשנות את הקוד שלנו בכמה מקומות. אנחנו גם רוצים ששינוי ברכיב אחד לא ישפיע על רכיב אחר, כי אנחנו לא אוהבים כפל קוד ולהתחיל לחפש ב- 10 מקומות איפה צריך לשנות/להוסיף את מה שאנחנו רוצים, וכתיבה בצורה הזו היא אבן יסוד בתכנות מונחה עצמים. אנחנו לא רוצים גם להמציא את הגלגל, אין שום צורך, אבותינו וחכמינו זצ״ל כבר חשבו על בעיות נפוצות וגם חשבו על דרכים לפתור אותם. אם אני רוצה ליצור מכונית, יש כבר אנשים שחשבו על ה״תבנית״, מנוע, 4 גלגלים, הגה ועוד... לא צריך להמציא כל פעם את הגלגל מחדש... תרתי משמע :) נכון שזה לא פותר לנו את העיצוב של כל המבנה, אבל זה אומר שאני לא צריך להמציא כל דבר קטן. לפתרונות כאלה קוראים ״תבניות עיצוב״. בתמונה: התנ״ך של תבניות העיצוב:  Design Patterns(1994)   ניתן עוד דוגמה להמחשה, אנחנו פותחים סטארט-אפ וכותבים אפליקציה לניהול לוגיסטי. האפליקציה שלנו בהתחלה יכולה להתמו...

Page Object Model, what is it ?

Image
Page Object Model (POM)   is a Design Pattern that has become popular in test automation for enhancing test maintenance and reducing code duplication. Benefits of using page object pattern : Creating a reusable code that can be shared across multiple test cases. Reducing the amount of duplicated code Duplicate browser action. Duplicate page action. Duplicate element action. If the user interfaces changes, the fix needs changes in only one place. Starting a UI Automation in Selenium WebDriver is NOT a tough task. We just need to: Find elements Perform operations on it Verify the result Example of a simple test ( without implementation of POM) As you can see... all we are doing here is finding elements and filling values for those elements. This is a small script, script maintenance looks easy now, but with time, the test suite will grow and we'll add more and more lines to your code... and things become tough. The main problem with script maintenance is if 10 different scripts ar...