Watir 6.7.0 is now available on RubyGems! A bunch of new features.
To install:
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:
Table Features
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.
OList
andUList
each effectively have a collection ofLI
Table
effectively has a collection ofTableRow
TableRow
effectively has a collection ofTableCell
Now you can iterate over them as if they were a collection like:
Siblings
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.
Original Window
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
use page-object.gem
, you likely won’t see anything new from this.
Checkbox
#set
,#set?
, and#clear
can now be handled with#check
,#checked?
and#uncheck
respectivelyElement#attribute_value
can now be accessed withElement#attribute
(also like Selenium)- Added support for
Element
#scroll_into_view
,#location
,#size
,#height
,#width
and#center
/#centre
Radio
#set
and#set
can now be handled with#select
and#selected?
respectively
See the Changelog for the complete history of updates.