Watir 6.7.0 is now available on RubyGems! A bunch of new features.
or in your Gemfile:
HTML5.1 and SVG2 Support
There have been some bugs and inconsistencies with these features, but they have been addressed in this release.
Watir now parses the latest official W3C HTML & SVG standards to automatically generate Element classes with their officially supported attributes.
These can be used for both element location and obtaining attribute values in a properly encapsulated fashion:
Non-standard attributes for elements can still be located and returned with:
Working with tables can be a challenge. Often it is easy enough to get the Table cell you need, but have to interact with elements in relation to it. Here are two useful ways to make this easier:
Iterating with Elements
Some elements can in some respects be considered Collections.
UListeach effectively have a collection of
Tableeffectively has a collection of
TableRoweffectively has a collection of
Now you can iterate over them as if they were a collection like:
Element#siblings returns an
HTMLCollection of all of the elements that are
direct children of the calling element’s parent. Note that the element
calling this method is included in the results. As with all adjacent methods,
this method accepts a hash that will filter the results by any valid Watir locator.
We can have long debates about this, and you are free to disagree, but I am not a fan of using Ruby blocks when they are merely used to manage a simple order of code execution (as opposed to using it to reference variables not defined until the context of the calling method).
To switch to a window, take an action, and return to the original window you can currently:
With this update you can now use a second window procedurally without having to explicitly store a variable:
Stealing From the Page Object Gem
While going through Cheezy’s updated Page Object gem, I found a number of
features that deserve be included directly in Watir. If you already
page-object.gem, you likely won’t see anything new from this.
#clearcan now be handled with
Element#attribute_valuecan now be accessed with
Element#attribute(also like Selenium)
- Added support for
#setcan now be handled with
See the Changelog for the complete history of updates.