In QTP, there is a concept called “Object Repository”. All the objects are added to Object Repository and the objects are used in the test. If there are any changes in the application then we need to update only Object Repository. But in selenium WebDriver, There is no any built-in facility to create object repository. So maintenance of page objects(Page element locators) becomes very hard If you will write all objects of page on code level.
Yes, we can use the below ways to create selenium WebDriver object repository:
A basic object repository can be implemented as a collection of key-value pairs, with the key being a logical name identifying the object and the value containing unique objects properties used to identify the object on a screen.
Instead of using locators directly in the tests we are going to use the locators in the form of static variables. Hence, there is no need to make any change to test cases, the only place where we need to make change is the “Class” containing static variable.
In QTP we can add object easily just using mouse, but in selenium WebDriver, it’s hard, yes, we can use the following ways to identify object:
- Selenium IDE
- FireFox – firebug, firepath
- Chrome Developer Tool
- IE Developer Tool
But it’s hard and time consuming, especially for newer in selenium automation, e.g., they need to know how to generate relative xpath although they don’t know what is xpath.
So now we have a solution, create a new little tool help us with object recognition, it’s very easy for any people, even they don’t know any relevant skills.
- Open the page you want to spy;
- Mouse over the element you want to spy;
- The relevant locator will display automatically;
- Right-click, copy any locator you need
This is our first implementation, maybe in the following time, we can create a ‘real’ object repository(not belongs to the automation project):) we can add object just as QTP does, then we can use it generate selenium ‘Page Object’ script automatically. and maybe more and more…..