Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

1 like 0 dislike
1.9k views
by Contributing Tester (42 points)
retagged by
Hi,

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

0 like 0 dislike
by The go-to Tester (181 points)
selected by
 
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.

Eg.

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 Login.java and whatever elements I identify on Dashboard, I put it in Dashboard.java. 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.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...