Watir
Encyclopedia
Web Application Testing in Ruby (or Watir, pronounced "water") is a toolkit used to automate browser-based tests during web application development
. This automated test tool uses the Ruby (programming language)
scripting language to drive Internet Explorer
, Mozilla Firefox
, Google Chrome
, Opera
and Safari
, and is available as a RubyGems
gem. Watir was primarily developed by Bret Pettichord and Paul Rogers.
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.
Web application development
Web application development is the process and practice of developing web applications.-Risk:Just as with a traditional desktop application, web applications have varying levels of risk. A personal home page is much less risky than, for example, a stock trading web site. For some projects security,...
. This automated test tool uses the Ruby (programming language)
Ruby (programming language)
Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...
scripting language to drive Internet Explorer
Internet Explorer
Windows Internet Explorer is a series of graphical web browsers developed by Microsoft and included as part of the Microsoft Windows line of operating systems, starting in 1995. It was first released as part of the add-on package Plus! for Windows 95 that year...
, Mozilla Firefox
Mozilla Firefox
Mozilla Firefox is a free and open source web browser descended from the Mozilla Application Suite and managed by Mozilla Corporation. , Firefox is the second most widely used browser, with approximately 25% of worldwide usage share of web browsers...
, Google Chrome
Google Chrome
Google Chrome is a web browser developed by Google that uses the WebKit layout engine. It was first released as a beta version for Microsoft Windows on September 2, 2008, and the public stable release was on December 11, 2008. The name is derived from the graphical user interface frame, or...
, Opera
Opera (web browser)
Opera is a web browser and Internet suite developed by Opera Software with over 200 million users worldwide. The browser handles common Internet-related tasks such as displaying web sites, sending and receiving e-mail messages, managing contacts, chatting on IRC, downloading files via BitTorrent,...
and Safari
Safari (web browser)
Safari is a web browser developed by Apple Inc. and included with the Mac OS X and iOS operating systems. First released as a public beta on January 7, 2003 on the company's Mac OS X operating system, it became Apple's default browser beginning with Mac OS X v10.3 "Panther". Safari is also the...
, and is available as a RubyGems
RubyGems
RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries , a tool designed to easily manage the installation of gems, and a server for distributing them. It is analogous to EasyInstall for the Python programming...
gem. Watir was primarily developed by Bret Pettichord and Paul Rogers.
Functionality
Watir makes use of the fact that Ruby has built in OLE capabilities. As such it is possible to drive Internet Explorer programmatically. Watir operates differently than HTTP based test tools, which operate by simulating a browser. Instead Watir directly drives the browser through the Object Linking and EmbeddingObject Linking and Embedding
Object Linking and Embedding is a technology developed by Microsoft that allows embedding and linking to documents and other objects. For developers, it brought OLE Control eXtension , a way to develop and use custom user interface elements...
protocol, which is implemented over the Component Object Model
Component Object Model
Component Object Model is a binary-interface standard for software componentry introduced by Microsoft in 1993. It is used to enable interprocess communication and dynamic object creation in a large range of programming languages...
(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.
Similar tools
- Celerity is similar to Watir, but emulates a browser instead of driving a real browser.
- Vapir is a Watir fork with bug fixes, API changes and new functionality.
- WatiN stands for Web Application Testing In .NET. It is similar to Watir, but is implemented in .NET Framework.NET FrameworkThe .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...
. - Watij stands for Web Application Testing in Java. It is similar to Watir, but implemented in JavaJava (programming language)Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
. - Win32-Watir is similar to Watir, but implemented in PerlPerlPerl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...
. - win-control is similar to Watir, but implemented in Gambit (Scheme implementation)Gambit (Scheme implementation)Gambit, also called Gambit-C, is a free software Scheme implementation, consisting of a Scheme interpreter, and a compiler which compiles Scheme to C. Its documentation claims conformance to the R4RS, R5RS, and IEEE standards, as well as several SRFIs...
. - Selenium (software)Selenium (software)Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language . It also provides a test domain-specific language to write tests in a number of popular programming languages, including...
is a portable software testing framework for web applications. - iMacrosIMacrosiMacros is an extension for the Mozilla Firefox, Google Chrome, and Internet Explorer web browsers which adds record and replay functionality similar to that found in web testing and form filler software. The macros can be combined and controlled via JavaScript. Demo macros and JavaScript code...
is similar to Watir, but includes visual recording, web scrapingWeb scrapingWeb scraping is a computer software technique of extracting information from websites...
support and a COM object for use with any programming language (Windows only) - Watir for Rails is similar to Watir, but it uses Selenium WebDriver and is integrated to Rails 3.
Recorders
There are a few recorders that can create Watir scripts, but none of them are supported by the Watir community. Watir forums normally do not entertain questions on recorders as they expect such questions to be raised in forums specific to the recorder(s).- CubicTest is a graphical Eclipse plug-in for writing Selenium and Watir tests.
- Firewatir-Gen translates the XML output from TestGen4Web into Watir code: Firewatir-Gen at code.google.com, Firewatir-Gen at rubyforge.org.
- TestWise Recorder is a Firefox 3 extension, which records your operations into executable RWebSpec and Watir test scripts while you navigates through your web application in Firefox.
- Watir Recorder (or Watir Maker) is a utility for Watir test developers which will record actions in a browser.
- Watir Recorder Sharp is a fork of Watir Recorder written in C#.
- Webmetrics Script Recorder allows users to record and playback their navigation through a series of steps on any website or application to generate a simple, human readable, Watir-compatible script.
See also
- Acceptance testing
- Regression testingRegression testingRegression testing is any type of software testing that seeks to uncover new errors, or regressions, in existing functionality after changes have been made to a system, such as functional enhancements, patches or configuration changes....
- Selenium (software)Selenium (software)Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language . It also provides a test domain-specific language to write tests in a number of popular programming languages, including...
- HtmlUnitHtmlUnitHtmlUnit is a headless web browser written in Java. It allows high-level manipulation of websites from other Java code, including filling and submitting forms and clicking hyperlinks. It also provides access to the structure and the details within received web pages. HtmlUnit emulates parts of...
- iMacrosIMacrosiMacros is an extension for the Mozilla Firefox, Google Chrome, and Internet Explorer web browsers which adds record and replay functionality similar to that found in web testing and form filler software. The macros can be combined and controlled via JavaScript. Demo macros and JavaScript code...
- Jaxer