Tuesday, 4 April 2017

How to use JSON file as Object Repository in Ruby ?


Note| 
 
Text in Blue [#PYTHON], Red [#RUBY], and Orange [#JAVA] can be edited or mentioned important for the entire blog. All the posts are practically done by me.


JSON as Object Repository in Ruby


Create a JSON formatted object repository file; say, or.json

{
  "login_id": {
    "selector": ":css",
    "value": "#login"
  }
}

Now, create a module; say, utilities.rb

module Modulename
def loc(element)
  file = File.read(File.dirname(__FILE__) + "/../helpers/or.json")
  @driver.find_element(eval(JSON.parse(file)["#{element}"]['selector']), JSON.parse(file)["#{element}"]['value'])
end
end

Add the path in your env.rb

require File.dirname(__FILE__) + "/../helpers/utilities"
include Modulename

Finally call the loc() method in a page file as shown below,

loc("login_id").click

38 comments:

  1. nice blog. helped me a lot. share some more tutorials???????

    ReplyDelete
  2. Amazing, thanks a lot my friend, I was also siting like a your banner image when I was thrown into Selenium.
    When I started learning then I understood it has got really cool stuff.
    I can vouch webdriver has proved the best feature in Selenium framework.
    thanks a lot for taking a time to share a wonderful article.
    Best Selenium Training Institute in Chennai |
    Selenium Training in Velachery

    ReplyDelete

  3. Its very useful to me. Wonderful blog.. Thanks for sharing informative Post.

    Installment loans
    Payday loans
    Title loans

    ReplyDelete
  4. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me.Thanks for sharing.java training in chennai

    ReplyDelete
  5. Awesome Tips here. This is really great and informative post. Best Online Website Development Courses

    ReplyDelete
  6. Thanks for sharing your post. Apartments for sale in Anna nagar available at affordable prices with world class amenities and international standard clubhouse. Do check out!

    ReplyDelete
  7. Thanks for The Post.Great Blog With unique Content And Nice Information.
    Thanks@Learn Selenium Webdriver

    ReplyDelete
  8. This information you provided in the blog that is really unique I love it!! Thanks for sharing such a great blog. Keep posting..
    Selenium Training
    Selenium Training Institute
    Selenium Course

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. 6-week summer course in Noida - 6 weeks The summer course plays a crucial role in shaping the career of young aspiring / informatics students. This training has been specifically introduced so that students can become familiar with current industrial culture and industrial needs. Webtrackker technology offers a 6-month training program for students / graduates that includes small and large projects.
    6-week summer course in Noida

    ReplyDelete
  11. All the latest updates from the Python Automationminds team. Python Automationminds lets you program in Python, in your browser. No need to install any software, just start coding straight away. There's a fully-functional web-based console and a programmer's text-editor
    Phyton training in Chennai

    ReplyDelete
  12. Thanks for giving this article. It was very helpful and also very informative.Keep updating like this.
    Best Data Science Online Training Institute In Hyderabad

    ReplyDelete
  13. Each department of CAD have specific programmes which, while completed could provide you with a recognisable qualification that could assist you get a job in anything design enterprise which you would really like.

    AutoCAD training in Noida

    AutoCAD training institute in Noida


    Best AutoCAD training institute in Noida

    ReplyDelete
  14. Video editing course in Noida
    Video editing training institute in Noida- Webtrackker Technology is and IT Training institute providing the Video editing course in Noida, FCP, Final Cut Pro Training in Noida. For more call us- 8802820025.
    Video editing course in Noida
    Company Address:
    Webtrackker Technology
    C- 67, Sector- 63, Noida
    Phone: 01204330760, 8802820025
    Email: info@webtrackker.com
    Website: http://webtrackker.com/Best-training-institute-Video-editing-FCP-course-in-Noida.php

    ReplyDelete
  15. Cloud Computing Training In Noida
    Webtrackker is IT based company in many countries. Webtrackker will provide you a real time projects based training on Cloud Computing. If you are looking for the Cloud computing training in Noida then you can join the webtrackker technology.
    Cloud Computing Training In Noida , Cloud Computing Training center In Noida , Cloud Computing Training institute In Noida ,

    Company Address:
    Webtrackker Technology
    C- 67, Sector- 63, Noida
    Email: info@webtrackker.com
    Website: www.webtrackker.com
    http://webtrackker.com/Cloud-Computing-Training-Institutes-In-Noida.php

    ReplyDelete
  16. I have read your blog its very attractive and impressive. I like it your blog.For more details please visit.
    Click here: Selenium Training in Hyderabad

    ReplyDelete
  17. Like different elements of India, numerous oil and spices usually cross into making food. This effects in substances getting caught to the partitions of the filter out.
    Visit here
    http://kitchenware.ml
    Best kitchen chimney installation and service
    Auto clean chimney sevice in Faridabad

    ReplyDelete
  18. myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance

    ReplyDelete
  19. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.




    selenium training in chennai


    java training in chennai

    ReplyDelete
  20. Amazing Article ! I have bookmarked this article page as i received good information from this. All the best for the upcoming articles. I will be waiting for your new articles. Thank You ! Kindly Visit Us @ Coimbatore Travels | Ooty Travels | Coimbatore Airport Taxi

    ReplyDelete

  21. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

    python Training in Bangalore | python Training in Bangalore

    ReplyDelete
  22. GlobalEdx is a pioneer in innovative learning with a blend of online, classroom and virtual training courses. It is an education platform that partners with expert content provider individuals and organizations worldwide, to offer blended courses for anyone taking their first step to a new job, next step for a better job, or for an organization or individual with personalized learning needs.

    ReplyDelete
  23. We also offer unified functional testing course for non selenium works. for more details please visit :
    https://globaledx.com/Become-a-Certified-Unified-Functional-Tester

    ReplyDelete
  24. We also offer unified functional testing course for non selenium works. for more details please visit

    ReplyDelete
  25. Thanks for providing the information . The articles in your blog helped me a lot for improving the knowledge on the subject. Also check my small collection on this at selenium Online Training blog

    ReplyDelete
  26. Amazing Article ! Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp greaorkst deal more around this condition. We also offer unified functional testing course for non selenium works. for more details please visit :
    https://globaledx.com/Become-a-Certified-Unified-Functional-Tester

    ReplyDelete
  27. Great info. I love all the posts, I really enjoyed,
    nice post and site, good work!
    I would like more information about this, because it is very nice.
    linux training in hyderabad

    ReplyDelete