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

36 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. 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
  4. Thanks for The Post.Great Blog With unique Content And Nice Information.
    Thanks@Learn Selenium Webdriver

    ReplyDelete
  5. 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
  6. This comment has been removed by the author.

    ReplyDelete
  7. 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
  8. 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
  9. 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
  10. 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

  11. 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
  12. 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
  13. 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
  14. We also offer unified functional testing course for non selenium works. for more details please visit

    ReplyDelete
  15. 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
  16. 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
  17. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command
    best rpa training in bangalore
    rpa training in pune | rpa course in bangalore
    RPA training in bangalore
    rpa training in chennai

    ReplyDelete
  18. I’m usually to blogging and i actually appreciate your content. The article has genuinely peaks my interest. I’m going to bookmark your web page and maintain checking for new details. I am looking for some good blog sites for studying. I was searching over search engines and found your blog site. Well i like your high quality blog site design plus your posting abilities. Keep doing it.
    Laptop Water damage service in chennai
    Laptop screen replacement in chennai
    Laptop battery replacement in chennai
    Laptop unlocking service in chennai
    Laptop display replacement in chennai

    ReplyDelete
  19. Are you looking for Distance Learning Courses in India most of the students choose and apply, Talentedgenex there are many popular courses which attract the students for having distance education. For more info visit this site:- Distance learning courses in India ,

    ReplyDelete
  20. Talentedgenext Way of Online Learning, Distance Education, is an increasing number of becoming popular all over the world due as it has many benefits. For further details visit in this site:- Distance Education Website,

    ReplyDelete
  21. Untuk memulai permainan judi domino qq, masing-masing pemain akan diberikan tiga buah kartu oleh bandar permainan
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terpercaya
    hobiqq
    paito warna terlengkap
    bocoran sgp

    ReplyDelete
  22. Awesome blog. It was very informative. I would like to appreciate you. Keep updated like this Best selenium training institute in Pune

    ReplyDelete
  23. If you're trying to lose pounds then you certainly need to get on this brand new personalized keto meal plan diet.

    To create this keto diet service, licenced nutritionists, fitness couches, and professional chefs joined together to develop keto meal plans that are efficient, suitable, economically-efficient, and fun.

    From their launch in 2019, 1000's of clients have already transformed their figure and well-being with the benefits a professional keto meal plan diet can give.

    Speaking of benefits; clicking this link, you'll discover eight scientifically-confirmed ones given by the keto meal plan diet.

    ReplyDelete
  24. I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favourites blog site list and will be checking back soon.

    Selenium Training in Electronic City

    ReplyDelete
  25. Awesome... You have clearly explained …Its very useful for me to know about new things... Keep on blogging...
    Microsoft Azure Training in Electronic City

    ReplyDelete
  26. Compre documentos en línea, documentos originales y registrados.
    Acerca de Permisodeespana, algunos dicen que somos los solucionadores de problemas, mientras que otros se refieren a nosotros como vendedores de soluciones. Contamos con cientos de clientes satisfechos a nivel mundial. Hacemos documentos falsos autorizados y aprobados como Permiso de Residencia Español, DNI, Pasaporte Español y Licencia de Conducir Española. Somos los fabricantes y proveedores de primer nivel de estos documentos, reconocidos a nivel mundial.

    Comprar permiso de residencia,
    permiso de residenciareal y falso en línea,
    Compre licencia de conducir en línea,
    Compre una licencia de conducir española falsa en línea,
    Comprar tarjeta de identificación,
    Licencia de conducir real y falsa,
    Compre pasaporte real en línea,

    Visit Here fpr more information. :- https://permisodeespana.com/licencia-de-conducir-espanola/
    Address: 56 Guild Street, London, EC4A 3WU (UK)
    Email: contact@permisodeespana.com
    WhatsApp: +443455280186

    ReplyDelete
  27. What’s up, I wish for to subscribe for this website to get latest updates, therefore where can I do it please help out.

    Result of B.Com Examination for 1st 2nd 3rd Year

    ReplyDelete