I'm new with Selenium.
Can you please explain What is Object Repository in Automation?
Object Repository is a centralized location where we can store objects information, it acts as interface between Test script and application in order to identify the objects during the execution.
We always recommend using external file for object repository rather than hard coding the objects and its properties directly into our code. If you are asking me why this is?
Reason is as it reduces the maintenance effort and provides positive ROI, for example say any of the object properties change within our application under test, we can easily change it in external object repository file, rather than searching and doing updates for that object individually in the code.
EX: we use a .properties file in Java
I disagree about the usefullness of the object repository in Selenium WebDriver test automation projects.
In my opinion, using object repositories in Selenium projects is a bad practice.
The object repository concept comes from record-and-playback tools such as QTP.
The object repository is a tree-like structure that is created while recording a test.
It has attributes for each element of the page used in the test.
Selenium does not have any record-and-play feature for test automation (Selenium IDE is not an automation tool).
Using object repositories in Selenium projects (as property or csv or xml files) has many disadvantages such as
since each locator is a line in a text file, it is impossible to open the declaration of the locator in the IDE (using F3 or Open Declaration)
page object classes with no locator variables break the class encapsulation principle (methods of a class should execute on variables of a class)
object repositories do not scale well for big pages; since big pages are bad and should be broken down in small pages, should we not have object repositories for each page widget?
object repositories do not work with page factory
Read more about the disadvantages on this medium.com article.
It's where you define objects (meaning the HTML definition of web page parts) and how they are grouped into application pages and page sections that represent logical groupings of information in the application.
Think of a scenario where you have a Webpage and it has multiple sections, multiple frames and hundreds of WebElements. Obviously you do not want that once you type the page name and it will give you all the elements available on the webpage. If there are few elements, it is fine to have the same structure but if there are many then it is advisable to divide your page in to different sections for e.g. header, footer, left navigation, center content and right navigation. Then categories each WebElement under their parent element.