In this video, We are going to cover a very important topic for the Selenium interview and answers for experienced people, What is the main difference between Page Object Model and Page Factory in Selenium.
✅ What is Page Object Model?
Page Object Model (POM) is a design pattern, mostly used in test automation with selenium that creates Object Repository or OR for web UI elements(with Page object Classes.
We use the Page Object model because it reduces code duplication and improves test maintenance.
There are two important things -
There should be a corresponding Page Class
Page methods which perform operations on those WebElements
✅ Why Page Object Model?
object repository is independent of test cases
Provides Structure to Automation Framework
✅ What is Page Factory in Selenium?
Page Factory in Selenium is an inbuilt Page Object Model concept for Selenium WebDriver but it is very optimized.
It is used for initialization of Page objects or to instantiate the Page object itself. It is also used to initialize Page class elements without using "FindElement/s."
Here as well, we follow the concept of separation of Page Object Repository and Test Methods. Additionally, with the help of PageFactory class, we use annotations @FindBy to find WebElement. We use initElements method to initialize web elements
@FindBy can accept tagName, partialLinkText, name, linkText, id, css, className, xpath as attributes.
✅ Want to become an Automation Rockstar ? https://thetestingacademy.com/
👪 Join our Community - http://bit.ly/learntesting2019
✅ Automation Community - https://thetestingacademy.com
🐦Follow us on Twitter - https://twitter.com/itstechmode
📖 Like us on Facebook - https://www.facebook.com/scrolltest
🎤 Listen to our Podcast - https://anchor.fm/thetestingacademy
🚀 Tools and services I recommend:
Some of the courses that I recommend to become better Automation Tester 🙌🙌
✅API Testing -
✅Cypress Tutorial with LIVE Projects -