Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

What is difference between POM and Page factory in selenium webdriver Java?

Solved 1 Answers 841 Views
1 1

What is the difference between Page object model and Page factory model in selenium webdriver Java?

I want to know each one with detailed examples .Is it possible to use with Selenium C# also?

Kindly reply me.

1 Answer

Best answer

In POM (Page Object Model) you create new class for every new page/URL and put all your element identification methods in it.


If you navigate to my Github - OrangeHRM automation sample project, you will notice that I have two .java files there. Dashboard and Login. So whatever element I identify on Login page, I put in and whatever elements I identify on Dashboard, I put it in This is really helpful in terms of maintenance and usability. So, if I want to work with any element present on Dashboard, I just have to say Dashboard.element. If case of change of element, I just have to change it at one place.

Page Factory is annotation inside selenium which you give it to class. So, when you define any class as page factory, all your elements inside the class will get loaded while any of element in the class is called. This is really a bad practice if you have 100s elements inside a class and you just have to make use of only one.

So, I would suggest you to go with POM. I do not have C# example, but I have similar one in Java which I have already shared.

Feel free to comment back if you need more details.

answered by (151 points)
selected by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.