What is POM (Page Object Model) in software testing Framework || How POM works? Benefits of using POM Structure

 

Pageobjectmodel

What is POM?

POM stands for page object model. This structure is widely use in software testing framework to maintain robust and easy-to-debug structure. 

POM Structure creates an object repository to store all the WebElements. 

In the POM design structure, we follow 3 Package pattern to store different files:

Note: We use constructors in all the POM files to traverse the driver from one page to another

  • Locators  - The POM Structure implementation starts from Locators Page. Here we add all the locators for the page under the test
  • Actions - After adding the locators we create the Actions Page we need to perform on each locator
  • Test  - After defining the locators and actions, we move toward the Test Page creation and use the actions and locators to perform our test.

How the Page structure looks on selenium?


SeleniumPOM



Implementation >>>>

PageObjectModelFramework




Execution >>>>

PageObjectModelFramework



Code Base Example for Locators File

  • Here we use encapsulation to create private locators and access them with public getters.

    • @FindBy annotation in selenium is the replacement for: 
      • driver.findElement(null)

    • As we are using @FindBy we need to add >> PageFactory.initElements(this.driver, driver); to avoid no such element exception

SelenumLocators



Code Base Example for Actions File


Selenoim_pageobjectmodel

Code Base Example for Test File

Selenoim_pageobjectmodel









Comments