objectRepository

As we discussed earlier, Object Repository is a collection of objects and it’s associated properties through which the object can be identified by the test automation tool during test execution. Automation testing tool identify the objects/elements by using their properties like name, id, xpath etc. You have to create your object repository in Selenium WebDriver. We can maintain the object repository in various formats. Here we will discuss following 3 mostly used ways to create object repository.

  • ·         Object Repository similar to intellisense available in VS or UFT
  • ·         Object Repository in properties file
  • ·         Object Repository in xml file

There are 3 files in each example.

Object Repository file: This file stores all objects with its associated property.

Object Map file: It contains the logic to fetch the actual objects from the object repository using their property and provides these to the main file. It mainly maps the logical object to actual object.


Main File: This file contains logic to execute test cases. It calls the functions defined in Object Map file to get the actual objects/elements and perform test case execution. 


I will use 3 pages as shown in bellow images (Home page, Login page and My Account Page) in my next couple of examples.


Home page: .Click on Login to to to Login page.

Login Page: If you click on Login it will navigate to logIn page where it will ask for Email and Password as shown bellow.



My Account Page:  After Login, it will navigate to My account page. To logout click on your name and then Logout as shown in bellow image.




Let starts the fun:

Create one java project and name it “DesignObjectRepository” in eclipse.
Inside this project create two packages name them as “objectRepositoryFile” and “objectRepositoryMain”. We will create the object repository file inside “objectRepositoryFile” package and class file to access the object repository file in “objectRepositoryMain” package.


Now the project structure in eclipse should look like the given bellow image.


Please visit the following individual link to impliment each type of object repository.

No comments:

Post a Comment