I’ve gone back and forth on this, and am sort of having a hard time deciding if a “Base page” class is necessary or a good idea.
In most cases this base page class someone stores common functions (or sometimes common locators like headers/footers) and a lot of time these are abstract classes with abstract methods that all child page classes should have (Such as a goto/navigate method all page objects may have or similar “action” methods).
However, I have also seen others argue that we should prefer composition over inheritance: https://stackoverflow.com/questions/49002/prefer-composition-over-inheritance which means we should use utility classes or classes that hold action methods and then use components to pull into our other PoM classes (In the case of a common component such as a header/footer)
I’ve conflicted in whether a base class really ever has a place for PoM? Personally i’ve only ever housed methods such as a goto method that all PoM sub-classes SHOULD have but even that’s probably not 100% necessary.
What are the benefits to one way over the other, and if there is a base class what should be in it?
Source: Read More