Spread the love

Object Repository Concept In Selenium

Spread the love

Object repository is place where we store all information related to an object. Typically in Quick Test Professional it is an optional part.[Descriptive programming]. But we use it regularly. We depend on QTP to identify object during run time and play back time.
The below written posts you help you to get more details about the same:

But when it comes to selenium there are way to store Object’s properties.
In selenium we generally store the xpath or relative paths or locator information.

usrname_txt=//*[@id='username']
passwd_txt=//*[@id='passwd']

The ways you can store these are..

  • Excel–Here you need POI jar to read and write
  • Notepad/CSV–File operation in java
  • XML–File operation
  • Class page wise
  • Using Inner class[Nested class concept]
Excel will typically Look like-

LogicalName
PropertyType
Propertyvalue
!Yahoo Home Page
usrname_txt
xpath
//*[@id=’username’]
passwd_txt
xpath
//*[@id=’passwd’]

 XML format
!Yahoo Home Page
<Object name> usrname_txt <Property type> xpath < Property  Value>//*[@id=’username’]
<Object name> findppl_txt <Property type> classname < Property  value> searchIconBorder

Notepad format–
username,xpath,//*[@id=’username’]
password,xpath,//*[@id=’passwd’]

Class Page Wise
Class LoginPage{
     String userName=By.xpath(//*[@id=’username’])
     String password=by.xpath(//*[@id=’passwd’])
     …….
    ……..
}
But these are ok when you are a learner or your test is significantly low in size or time. These methods are not effective when your test is very big in nature or say test will be running for 3 days or 4 days.Also they need either a 3rd party jar like-POI or java’s file handling operation which are not great for architecture point of view when time is a constraint.

So What could be the solution..
I would prefer the inbuilt nested class structure approach should be taken when your test is really big.

let me explain how..


public static class LoginPage{
private static class Login{
String userName=By.xpath(//*[@id='username'])
String password=by.xpath(//*[@id='passwd'])
}
private static class bodyElement{
.......
........
}

}

READ  Why Xpath Is Slower in Browsers Specially In Internet Explorer?
READ  Learn Object Repository in UFT in An Efficient and Fast Manner

Well the advantages for this approach are–

  • Since they are static they will be loaded when you are trying to run login class. 
  • All objects will be available in Primary memory so no delay in execution of the test.
  • Readability will be easy but your test will remain huge
  • Less dependency on the external jars so delay in getting the data.
  • your primary memory will be free from the unwanted code.
  • Let JVM decide which objects and data will present on the memory  instead of us!!!
  • Garbage collection will be effectively fast.[Note we do not have any control on that programming] so helping GC by reducing load will be good from architecture point of view.




Spread the love
Animesh Chatterjeehttps://techtravelhub.com/
I am the founder and owner of the blog - TechTravelHub.com, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on ani01104@gamil.com

Related Articles

How to Resolve NoSuchSessionException in selenium free?

How to Resolve NoSuchSessionException in selenium? NoSuchSessionException in Selenium is a tricky...

Comments

Recent Posts

Super Keyword in Java Simplified

Super Keyword Super Keyword in Java Simplified: Java defines a special...

Learn Object Repository in UFT in An Efficient and Fast Manner

Object Repository in UFT The post will cover the following...

Learn What Primary Tools For Test Automation

Primary Tools For Test Automation According to the Gartner report...

EDITOR PICKS


Spread the love