Earn Money in 10 days

Selenium Videos

Protractor In Selenium

Livechat

Tuesday, 4 November 2014

What is object repository/Property file in selenium.


Why we used property file in Selenium?
Whats the need of Property File/Repository??
Parameterization of a particular test is needed in order to avoid hard coding of values. The following Example actually demonstrates the usage of parameterization.
Let us assume that our test suite contains more than 1000 test cases and more than 50 different screens and we have thousands of objects on the application under test.  Multiple test cases may be (more than 10) using a particular screen.  If there is a change request from the client to enhance / change any of the object, then we need to update all the test cases. So its very difficult to change in Test cases.For avoiding updation in Testcases.We Create an Object Repository.If there are any changes in the application then we need to update only Object Repository.
What is Object Repository/Property File
In QTP, there is a concept called “Object Repository”.  All the objects are added to Object Repository.
So how we will do this in Selenium..You will used this object repository in framework a lot.
How to use Object Repository In selenium?
Step1:Create a new Project>Click on Finish
Step2:Make a package as config>Click on Finish


Step3:Now Right Click on config(Packagename)>New>Other

Step4:Click on other>ClickGeneral>Click on File
Step5:Now enter the name of propertyfile..or.properties>Click on Finish

Step6:Now Add the details in property file
propertyfile for gmail login..

How to use Property file
Create a new class as ReadingPropertyFile


//Here is the code for Reading property file
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ReadingPropertyFile {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
//For reading property file we have to create object
    //Create an object of property class
//import property files.
Properties prop = new Properties();
//Now make an object of file input stream
//import the files after creating object
FileInputStream ip = new FileInputStream("D:\\User\\workspace2\\PropertyDemo\\src\\config\\OR.properties");
prop.load(ip);
System.out.println("load all propeties");
//launch instance of any browser
WebDriver driver = new FirefoxDriver();
//now open gmail/browser
driver.get("http://gmail.com");
//now pass the xpath by property file
driver.findElement(By.cssSelector(prop.getProperty("username"))).sendKeys("ritu7180");

driver.findElement(By.cssSelector(prop.getProperty("password"))).sendKeys("password");

driver.findElement(By.cssSelector(prop.getProperty("signup"))).click();
}

}
Reading property file is very easy.
Just Follow four steps:
Step1:make an object of Property class 
Properties prop = new Properties();
Step2:Make an Object of InputStreamClass
FileInputStream ip = new FileInputStream ip();
Step3:Pass the path of propertyfile in the fileinputstream constuctor.

Step4:load the property file by..
prop.load(ip);

39 comments:

  1. It’s too informative blog and I am getting conglomerations of info’s. Thanks for sharing; I would like to see your updates regularly so keep blogging.
    Software testing training|Software training

    ReplyDelete
  2. It was very clear to understand the concept of object repository property.
    Regards,
    Qtp training in Chennai|Qtp training |Loadrunner Training in Chennai

    ReplyDelete
  3. I agree with your post, the Introduction of automation testing product shortens the development life cycle. It helps the software developers and programmers to validate software application performance and behavior before deployment. You can choose testing product based on your testing requirements and functionality.
    Qtp training in Chennai|Qtp training |Loadrunner Training in Chennai

    ReplyDelete
  4. very usefull informatation in this Blog about Java

    ReplyDelete
  5. This information really worth saying, i think you are master of the content and thank you so much sharing that valuable information and get new skills after refer that post.
    CCNA Training in Chennai

    ReplyDelete
  6. Australia best tutor is well known academic portal. Here students can get different kind of Online Assignment help services like that

    1.Online Assignment Help
    2.Instant Assignment Help
    3.Assignment Help
    4.Help with Assignment
    5.my assignment Help

    And also access that services at any time and any where.

    ReplyDelete
  7. Thanks for posting your valuable information.keep updating such an wonderful article..DotNet Project Center in Chennai | DotNet Project Center in Velachery

    ReplyDelete
  8. Your good knowledge and kindness in playing with all the pieces were
    very useful. I don’t know what I would have done if I had not
    encountered such a step like this.

    white label website builder

    ReplyDelete
  9. VERY INFORMATIVE BLOG. KEEP SHARING SUCH A GOOD ARTICLES.
    IOT Services | Austere Technologies

    ReplyDelete
  10. Looking really very informative blog impressed with the article just keep do sharing on...
    Best Online Software Training Institute | Python Training

    ReplyDelete
  11. Awesome Blog, you have provided the right information that will be beneficial to us. Thanks for sharing your valuable Ideas to our vision. Comptia Network+ Certification Courses in Chennai | Best N+ Courses in Tambaram

    ReplyDelete
  12. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information, this is useful to me..
    Android Certifications Exam Center in Chennai | Best Android Exam in Mandaveli

    ReplyDelete
  13. Awesome post it's really useful from me..Kindly keep sharing such a nice post..
    Python Certifications Training Institute in Chennai | Python Coaching in Chromepet

    ReplyDelete
  14. very useful information. i am expecting more posts like this please keep updating us.......
    ISTQB Certifications Center in Chennai | ISTQB Training in Taramani

    ReplyDelete
  15. Excellent post which helps me to get the in depth knowledge about the technology..
    Python Certifications Exam Cost in Chennai | NO.1 Python Coaching in Adyar

    ReplyDelete
  16. very useful information. i am expecting more posts like this please keep updating us....
    No.1 ISTQB Certifications Exam Course in Chennai | Testing in Thiruvanmiyur

    ReplyDelete
  17. Hi Thanks for the nice information its very useful to read your blog. We provide best Chartered Accountancy

    ReplyDelete
  18. Hi Thanks for the nice information its very useful to read your blog. We provide best Certified Financial Analyst

    ReplyDelete
  19. Thank you for sharing this valuable information. But get out this busy life and find some peace with a beautiful trip. book ANDAMAN TOUR PACKAGE @24599

    ReplyDelete
  20. Thank you for sharing this valuable information. But get out this busy life and find some peace with a beautiful trip. book BEST ANDAMAN HONEYMOON PACKAGE @5999

    ReplyDelete
  21. Hi Thanks for the nice information its very useful to read your blog. We provide Software Development Services

    ReplyDelete
  22. Hi Thanks for the nice information its very useful to read your blog. We provide best Chartered Institute Of Management Accountants

    ReplyDelete
  23. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
    python training in hyderabad

    ReplyDelete
  24. It is very nice blog. The content of this blog is helpful for us with the informative and valuable information. Share your information and keep going on. Python Online Training

    ReplyDelete
  25. Hii…It was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly
    python training in hyderabad

    ReplyDelete

Popular Posts

 
subscribe
Subscribe Us
emailSubscribe to our mailing list to get the updates to your email inbox... We can't wait more to have your email in our subscribers email list. Just put your nice email in below box: