Everyday Scripting with Ruby

Brian Marick

Mentioned 2

Provides information on the basics of the Ruby scripting language and how to create scripts using test-driven design.

More on Amazon.com

Mentioned in questions and answers.

I have installed ruby 1.9.2 and watir on my windows 7 system. Now I want to automate my web browser. Suppose there are 10 different links which I want my browser to browse after certain amount of time. How do I do this? I am new to ruby and watir. Can someone suggest me how the process of coding would be or suggest me a site or an ebook where I can get material regarding this.

Since a lot of the basics of scripting (conditional logic, loops, waiting, etc) are relative to the basic Ruby language and not the specific classes and methods implemented by Watir, I'd suggest starting off with a good book on scripting with Ruby.

My favorite is by one of the original folks responsible for Watir itself, Brian Marick "Everyday Scripting with Ruby: for Teams, Testers, and You".

In terms of watir, there's the tutorials in the Watir wiki, and the book that Zelkjo is working on.

The thing you describe, is 90% scripting (repeating a given type of action, with a different input, after a specified time interval) and 10% watir (navigating to the link value), so I'd start with the scripting stuff first.

For someone on a budget, I would also offer the following "free" books (I put 'free' in quotes because I'm familiar with all the time and effort that goes into authoring a book, and these are not 'free'. They come at the expense of a lot of blood, sweat and tears on the part of authors/editors etc. who have then been generous enough to then offer up their work without pay. I think calling them 'free' devalues the labor that went into creating them.)

  • "Programming Ruby: The Pragmatic Programmers Guide" is often installed by the Ruby installer (depending on version) or can be accessed at the link above. I've used this more as a reference than a learning tool, but it might work for you.
  • Why’s (Poignant) Guide to Ruby, available in both HTML and PDF versions, is somewhat iconic in the Ruby community. I found the writing style amusing and got some good stuff out it it, but then I'v been programming in a variety of languages since the days of teletypes and 110baud acoustically coupled modems.
  • Mr. Neighborly’s Humble Little Ruby Book - I've not read this one, but it seems well regarded if a tiny bit out of date. Aaron Sumner said of it "it’s relatively short (under 150 pages) and in a very friendly, accessible tone. If you’re still getting familiar with the Ruby language itself, it’s as good an introduction as there is out there."

All of those are I think more geared to someone who already understands programming, and not as good for a new tester starting out doing automation. For that you'd be better served spending the money for Marik's book, Since he's worked as a tester, and understands testing, and the book is largely aimed at testers, I thus think you can get far more out of it. Seriously it may not be free, but consider it an investment in your education and career.

Ruby on Rails is an open source full-stack web application framework created by David Heinemeier Hansson (DHH) in 2004 using the Ruby programming language. It is an optimized framework aimed at programmer's happiness and providing sustainable productivity by making use of CoC (Convention over Configuration), DRY (Don't Repeat Yourself), Active Record Pattern and REST (Representational State Transfer) philosophies.

It is based on the MVC Architectural Design Pattern, which separates web applications into three different modules:

  • Model
  • View
  • Controller

This helps to isolate business logic from presentation and makes code maintenance significantly easier as well as more flexible.

Ruby != Ruby on Rails

The tag is for questions related to the Ruby on Rails framework. This tag is particularly appropriate for questions about:

  • Rails MVC patterns
  • Rails objects
  • Rails methods
  • Rails gems
  • Rails views
  • Rails routes
  • ActiveRecord object-relational mapping (ORM)

Questions about Ruby on Rails should not be tagged with [tag: ruby] unless the question is about the Ruby language in general, its syntax and libraries, or other questions not specific to the Ruby on Rails MVC framework.

Please see the Ruby tag wiki for more information about when it's appropriate to tag a question with [tag: ruby] instead of .

Specific Versions

Questions regarding specific versions of Ruby on Rails can also be asked on the appropriate tags:

Where to start:

Interactive Ruby:

  • Codecademy - Learn the fundamentals of Ruby and dynamic programming

Online Courses:

  • Web Application Architectures - Learn how to build and deploy modern web application architectures – applications that run over the Internet, whereas in the "cloud" technology, deploy it using a browser as the user interface. We're going to learn about web apps through the Ruby on Rails framework. Rails is a framework for creating web applications that are built on top of the Ruby programming language.

Resources:

Books:

When asking Ruby on Rails questions, you should:

  1. Read the API documentation carefully and search Stack Overflow for duplicates.
  2. Mention the Ruby and the Ruby on Rails version related to the issue.
  3. Frame the question in a simple way, add code snippets if that could help the community to understand the problem better.
  4. Tag the question with appropriate tags so that there will be more visits to the page.
  5. Supply error information, if any - console log info is best.

Contributing to the community:

  1. If you can solve the problem, spend some time by answering the question.
  2. Up-vote and down-vote appropriately to rate and maintain the quality of questions and answers posted.

Contributing to Ruby on Rails:

There are hundreds of people around the world who contribute to Ruby on Rails. You can start by following this guide.

Chat rooms:

Related tag