Storing objects in a property file

Answered

Which is a more convenient  way of storing objects in Selenium Web driver ? Either using property file or using Page Object Model ( declaring objects in class file and accessing them using PageFactory.initElements)

Default Asked on November 4, 2014 in Selenium WebDriver.
Add Comment
  • 4 Answer(s)
    Best answer

    Hi Mayur,

    Page Object Model using Java classes & Page Factory, both are different strategy to implement Page Object Structure. Both are equally good but what to use usually depend on your need. You may like to see which one is easy to understand and easy to maintain and which one fits for your project requirement. I have used both in my projects but still I am a lover of my own designed Page Object Model, as it is easy to understand and whenever I handover my project to my team to handle it, it is easy for them to understand and follow the pattern.

    Take a look over these topics:
    Page Object Model : http://www.toolsqa.com/selenium-webdriver/page-object-model/

    Object Repository : http://www.toolsqa.com/selenium-webdriver/object-repository/

    Following above topics you would be able to design a Page Object Model, which is very easy to follow for someone who have just the knowledge of Application and he/she working on automation script first time. For example I am an automation tester and it has been asked to me to develop scripts.

    Now all I know is to first go on Home Page and for that I will type just Home_Page and dot like this (Home_Page. ) The moment I press dot, it will return me all the objects and sections under the Home page. Then I will type let say header and dot like this (Home_Page.Header. ). Now it will display all the objects under only header part, not the whole Home page objects. It helps to identify the objects in much easy way, as I will just get the specific elements like Logo Image, Login Link, Register Link etc.

    Plus you would be able to do a separate logging for each of your page object element and you would be able to apply try catch statements around your elements etc.

    Still it is always up to you and for Page factory please go through this link:

    http://www.toolsqa.com/selenium-webdriver/page-object-pattern-model-page-factory/

    PS: Please do not forget to close your answer : http://forumsqa.com/selenium-webdriver/how-to-choose-best-answer-insert-code-vote-up-an-answer/

    Best Regards,

    Lakshay Sharma

     

    Professor Answered on November 5, 2014.
    Add Comment

    Hi Mayur
    I am not Sure What do You Mean By Objects , But i Guess you are Talking About Variables
    Generally we Store Frequently Changing Values in Property File (Say browsername,username, password,somedropdown values)

    But in PageObjects We Store Page Elements say Login Button ,Fields  etc

    Regards
    Ankit

    Vice Professor Answered on November 5, 2014.

    Thanks ankit for your suggestions .

    on November 5, 2014.
    Add Comment

    Thanks Lakshay for such a nice explanation.

    Default Answered on November 5, 2014.
    Add Comment

    Depends on your requirement and approach. If your assignment have large number of locators then you must go with page objects, if you have less locators you may go for properties file.

    Train Answered on November 17, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.