Browser Automation with Python and Selenium — 16: Page Object Model
Page Object Model for better structured and maintainable code

In the previous post, we explored managing window position and dimensions and also taking screenshots with Selenium. We will see Page Object Model(POM) to create more structured and maintainable code in this post.
Until now, we have used mostly functions and single modules for our examples. If you try to manage a web page with lots of pages or components with a wide range of interactions among them, things might get complicated with this approach.
This is a general problem and as always there is a common solution for this common problem with a design pattern called “Page Object Model”.
Before starting to use it, let’s first look at what it is.
Page Object Model is a popular design pattern in test automation to create an “Object Repository” for UI elements on a web page. It models web pages as objects.
Without using it, our code contains lines like in the snippet below that make WebDriver calls with unintuitive locators all over the project.