ArticleslgStudy

computer science

Watir

Watir is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Watir rather than just read about it. In short: Watir (Web Application Testing in Ruby, pronounced water), is an open-source family of Ruby libraries for automating web browsers. It drives Internet Explorer, Firefox, Chrome, Opera and Safari, and is available as a RubyGems gem.

Watir — main illustration
Watir — illustration

Key takeaways

  • Watir belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Watir to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Watir from memory before moving on to harder problems.

Reference excerpt

Watir (Web Application Testing in Ruby, pronounced water), is an open-source family of Ruby libraries for automating web browsers. It drives Internet Explorer, Firefox, Chrome, Opera and Safari, and is available as a RubyGems gem. Watir was primarily developed by Bret Pettichord and Paul Rogers.

Functionality

Watir project consists of several smaller projects. The most important ones are watir-classic, watir-webdriver and watirspec.

Watir-Classic Watir-Classic makes use of the fact that Ruby has built-in Object Linking and Embedding (OLE) capabilities. As such it is possible to drive Internet Explorer programmatically. Watir-Classic operates differently to HTTP-based test tools, which operate by simulating a browser. Instead, Watir-classic directly drives the browser through the OLE protocol, which is implemented over the Component Object Model (COM) architecture. The COM permits interprocess communication (such as between Ruby and Internet Explorer) and dynamic object creation and manipulation (which is what the Ruby program does to the Internet Explorer). Microsoft calls this "OLE automation", and calls the manipulating program an "automation controller". Technically, the Internet Explorer process is the server and serves the automation objects, exposing their methods; while the Ruby program then becomes the client which manipulates the automation objects.

Watir-Webdriver Watir-Webdriver is a modern version of the Watir API based on Selenium. Selenium 2.0 (Selenium-Webdriver) aims to be the reference implementation of the WebDriver specification. In Ruby, Jari Bakken has implemented the Watir API as a wrapper around the Selenium 2.0 API. Not only is Watir-Webdriver derived from Selenium 2.0, it is also built from the HTML specification, so Watir-Webdriver should always be compatible with existing W3C specifications.

Watirspec Watirspec is executable specification of the Watir API, like RubySpec is for Ruby.

See also

Acceptance testing Regression testing List of web testing tools Test automation

References

External links Watir home page Watir source code The Watir Podcast Cucumber & Cheese Archived 2013-12-07 at the Wayback Machine, a testers' workshop book by Jeff Morgan

Illustrations

Watir illustration

Worked examples

Example 1 — a first encounter with Watir

Start with the simplest possible case. Write down what Watir claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Watir before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Watir ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Watir

In research
Watir appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Watir in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Watir is common in secondary-school and first-year university syllabi. It links to neighbouring topics Graphical user interface testing, Ruby (programming language), Software using the BSD license, so understanding it makes those chapters shorter.
In everyday life
Look for Watir outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Watir” →

How to study Watir in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Watir means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Watir out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Watir in simple terms?

Watir (Web Application Testing in Ruby, pronounced water), is an open-source family of Ruby libraries for automating web browsers. It drives Internet Explorer, Firefox, Chrome, Opera and Safari, and is available as a RubyGems gem.

Why does Watir matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Watir?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Watir.

Tags

  • Graphical user interface testing
  • Ruby (programming language)
  • Software using the BSD license
  • Web development software
  • Web scraping

Keep exploring