I have a Class A (page object model) of page A. I have a Class B (page object model) of page B and so on...
I have another Class R that doesn't belong a specific page but it has list of locators to some of the reusable components of my application.
I have two questions to ask:
1. Will it be a good practice to say extend Class A or Class B with Class R and reuse the locators in Class R if required for the purpose of reusability? If yes do you suggest exposing getters in Class R for exposing it's locators? If no can you suggest the best practice?
2. Suppose in Class R there are locators related to a modals. Locators like title of modal, content of the modal and buttons in the modals. Now any page that have an action that opens up a modal would need these locators to ensure that the modal elements are visible. So instead of every class inheriting Class R and itself making those assertions(which is repeating set of assertions in every class file inheriting Class R for modal assertions) with the help of inherited locators of the modal from Class R. If I create a method in Class R say modalBasicValidations()
to do these basic checks and expose it, then every inheriting class can then use it. Is it a good practice? Any suggestions feedback thoughts?
Any other thoughts or any suggestions on best practices, any references etc.