Watir (Web Application Testing in Ruby), pronounced as “Water” is an open source tool developed using Ruby which helps in automating web application that suits applications developed in any programming language. The browsers supported for Watir installation Internet Explorer, Firefox, Chrome, Safari, and Edge. Watir is available as Rubygems for installation.
Watir will connect to the browser given and follows up the instructions of opening the URL, clicking on the button, entering data inside a textbox just as any real person will do. Watir is most commonly used for its browser support with testing frameworks like RSpec, Cucumber, etc.
Features of Watir
Watir is rich in features, as discussed below −
Location web elements − There are different ways you can locate web-elements rendered inside the browser. The ones mostly used are id, class, tag name, custom attributes, label etc.
Taking Screenshots − Watir allows you to take screenshot of the testing done as and when required. This helps to keep track of the intermediate testing.
Page Performance − You can easily measure page performance using the performance object which has properties like, performance.navigation, performance.timing, performance.memory and performance.timeOrigin. These details are obtained when you connect to the browser.
Page Objects − Page object in Watir will help us to reuse the code in the form of classes. Using this feature, we can automate our app without having to duplicate any code and also make it manageable.
Downloads − With Watir, it is easy to test file download for UI or website.
Alerts − Watir provides easy to use APIs to test alerts popup in your UI or website.
Headless Testing − Using headless testing, the details are obtained in the command line without having to open the browser. This helps to execute UI test cases at the command line.
Advantages of Using Watir
Watir offers the following advantages −
- Watir is an open source tool and very easy to use.
- Watir is developed in Ruby and any web application that works in a browser can be easily automated using watir.
- All the latest browsers are supported in Watir making it easy for testing.
- Watir has inbuilt libraries to test page-performance, alerts, iframes test, browser windows, take screenshots etc.
Disadvantages of Watir
Like any other software, Watir also has its limitations
- Watir is supported only for Ruby test framework and it cannot be used with any other testing frameworks.
- Mobile testing using Watir is not enhanced and desktop browsers are mimicked to behave like mobile browsers instead of acting as real time devices.
Leave a Reply