Search code examples
javaselenium-webdriverpageobjects

How to work with the web elements that are common in multiple web pages in selenium page object model?


I have many webelements that are same for every web page. Should I create a new page class for including all the common web elements?


Solution

  • Your question is more about understanding, so it depends on you how you want to design your code. As I am also doing the same so I will say Yes.

    Like you could create a base page class that includes a header and footer navigation bar, a login/logout button, and a search bar. Then, all other page classes that contain these elements can extend the base page class and only include the unique elements for that page. Folks can have different ideas and approaches. Its all depends on you.