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

25 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