Watir 6.16

Written by: Titus Fortner on December 16, 2018

Watir 6.16 is now available on RubyGems. Extensive scrolling functionality has been added from Alex’s watir-scroll gem and Element Location has been overhauled again for some performance improvements.

To install:

gem install watir

or in your Gemfile:

gem "watir", "~> 6.16"


The Watir team has frequently recommended Alex’s watir-scroll.gem to our users. After some discussion it was decided to maintain that functionality directly in Watir. If you are already using the latest version of watir-scroll, you can remove it from your gemfile and everything will just work, as the API has stayed exactly the same.

If you aren’t already using it, you should check to see if this functionality might be useful for you, it is invaluable when working with static css styles, “infinite scroll” pages, and elements inside of scroll bars.

Element Location

A lot of work has gone into completely redoing the locator class implementations the past couple months. In addition to the code being much cleaner, in many cases Watir can now locate nested elements with a single wire call instead of requiring multiple calls. If you use a lot of nested elements or Page Sections as part of your page object implementation, you might see a minor performance improvement.

An interesting comparison of wire calls for the following code:

# Clicking an Element nested 4 deep
fieldset = browser.body.form(name: 'user_new').fieldset(index: 2)
fieldset.checkbox(id: 'new_user_interests_books').click

Watir 6.3 (Original approach with lots of wire calls)

  • 33 Wire Calls: Window, Windows, Frame, Locate, Name, Enabled, Locate, Name, Enabled, Locate All, Name, Enabled, Locate, Name, Type, Enabled, Enabled, Enabled, Window, Windows, Frame, Enabled, Displayed, Enabled, Displayed, Enabled, Displayed, Enabled, Displayed, Enabled, Enabled, Click

Watir 6.4 (Big performance update Summer of 2017)

  • 6 Wire Calls: Locate, Locate, Locate All, Locate, Enabled, Click

Watir 6.10 (Reorganized things which made this use case worse)

  • 13 Wire Calls: Locate, Locate, Name, Locate All, Name, Name, Name, Name, Name, Locate, Enabled, Enabled, Click

Watir 6.11 (Big performance update Spring of 2018)

  • 6 Wire Calls: Locate, Locate, Locate All, Locate, Enabled, Click

Watir 6.13 (Optimized element location in collections)

  • 5 Wire Calls: Locate, Locate, Locate, Enabled, Click

Watir 6.16 (Combined nested elements into one location wire call)

  • 3 Wire Calls: Locate, Enabled, Click

Locator Extension Classes Updated

This only applies to add-on gems like watizzle.gem watir_css.gem and watigiri.gem, but the classes and methods that such gems implement will either need to be changed or have the Watir version restricted.

See the Changelog for the complete history of updates.


Thoughts about this article? Let us know!