Abstract Page, Abastract component, Page, Component and Container - alandiaz08/e2e-web-framework GitHub Wiki
The main purpose of an abstract class is to make the child classes use the methods inside it without instantiation.The only way we can use the methods inside abstract class is by extending the class. The keyword 'abstract' is added to the class declaration to indicate that it is an abstract class. It is also used to hide the implementation details from the rest of the classes.
-
As per the definition above, the abstract page and abstract component in WNG is primarily used to implement methods which are to be used across all the pages and components without the need for creating an object.
-
The methods which are common to all the page and component classes is to assign a driver and a container respectively for the execution are implemented inside the abstract page and component.
-
There are other abstract classes in our framework such as AbstractBookingModal, AbstractRestaurantInfo and AbstractSideBarPage which are extended by the relevant components and pages.
For example , in the following page, the close and back buttons are common across all the pages of the booking modal which is implemented in the parent AbstractBookingModal class.
A page is a part of a web application which contains all the necessary information and elements related to the functionality it serves. For example, a login page helps a user to login to the application and so it has text boxes for the username, password and a button to login which directs to the logged in page.
In WNG, some of the examples of pages are :
- Search Page - Contains the search results.
- Restaurant Page - Contains the restaurant information.
Components are the real functional part of a page. A specific action can be performed on them and they can be reused across different pages. Example , searchComponent which enables the user to search for a specific restaurant and city, is present in both homePage and SearchPage.
Containers can be defined as box which holds the components of a page. They are a simply a block of code. The main advantage of using a container is to localize the element search to the component level and not page level . In the following example, the block
has the search component and we can search for the element starting from this block.A page can have multiple components and each component is initialized with a container. The main purpose of splitting a page into components is to make the code readable, maintainable and reusable.
In WNG , the main purpose of SearchPage is to show the search results. We can directly access the elements of the page such as Maps, Search results and specify the date time and the number of pax. But if we do so, the code will be improperly organized and there won't be any modularity. It would be difficult to modify or update the elements if there is a change.
The best practice is to divide the entire page into Header, Google Maps, DHP, searchComponent and footer which makes them independent modules each performing a specific action. Each component should be initialized in a page which enables us to use the methods and locators defined inside them.
Special case : In some cases , there can be a component inside a component like how a booking item is inside a booking list. The need for such an arrangement is to organize and separate the actions performed on them.