Showing posts with label Advanteges of Object Repository. Show all posts
Showing posts with label Advanteges of Object Repository. Show all posts

Wednesday, 5 February 2014

Creating Object Repository in Selenium WebDriver

1.      What is Object Repository?

Object Repository is a place where we can store objects information, it acts as interface between Test script and application in order to identify the objects during the execution

2.      Uses of Object Repository

1.      Object repository is a centralized location of the objects and their properties, so that if any object information changed in AUT, you need not to change in all the scripts, it is enough to change in the Object repository
2.      Easily maintain your tests or components when an object in your application changes

3.      Creating Object repository:

It’s up to you create an object repository, and which file you want to use, you can use properties file, you can use XML file….etc. You can learn about this in framework design concepts during the training; you can find the source code to read the values from the object repository in the project provided during the training.
Let us discuss about few ways here to create a object repository: 

First way to Create OR File:


1.      After create a Project, Create a following project structure in your project(I am Assuming here my application is Yahoo, and I am Following POM framework)



                                
  Note: Here Sagara is my client Name
2.      Create a simple text file with the Extension as .OR  (ex: LoginPage.OR) under object Repository Package (here it is com.sagara.objectRepository)
3.      Create a Simple java class file under test Pages package (ex : LoginPage.Java)
After above steps, your project looks a like:

4.      Open your LoginPage.OR and write the objects informations like this :



5.      Open your LoginPage.Java, and write the below code to get the objects information's from the OR Page and use it

          

Second way to Create OR File:


1.       After Creating a project, make sure that you will be having the following project structure (It is optional)



2.       Create a simple Java Class under testObjects Package(Let us say YahooLoginPage.Java)
3.       Create a simple java class under testscripts Package  (Let us say ‘TestYahooLoginPage.java’)

       

         
4.       Open your YahooLoginPage.Java and write the below code :

                
5.      Open TestYahooLoginPage. Java and write the below code :



Congrats!!...Now you have learnt how to maintain Object Repository in selenium