Watir 6.8.0 is now available on RubyGems! Several new features including new methods to increase performance.
To install:
or in your Gemfile:
Bang Methods
Drivers are slow when it comes to typing text. Typically the intent of a test that enters text into a field is to verify:
- the user can type into the field
- the actions associated with events get fired
- the application properly handles the data
None of these three things require that a driver type each character.
By using a Element#set!
instead of Element#set
, Watir will:
- send clear via the applicable driver command to ensure the user can interact with the field
- use JavaScript to quickly fill the field with the specified text
- type the last character via the applicable driver command to ensure that appropriate events get fired
Depending on how much text is being entered, this could provide a huge performance improvement without negatively impacting the effectiveness of the test.
Along with Element#set!
, Watir now supports bang (!
) methods with
JavaScript implementations for:
Element#click!
Element#double_click!
Select#select!
Select#select_all!
The clicks are unlikely to provide a performance improvement and should be used sparingly. The Select methods have the potential to decrease the time it takes to interact with especially large select lists.
Let us know what kind of performance improvements you see with these methods.
Radio Sets
Input elements of type="radio"
are not independent (clicking one radio button in a
set will de-select another radio button in the set), but until now Watir has required
users to treat them independently. Element#radio_set
now allows users to
identify the collection of related radio buttons and interact with it
similarly to how one currently interacts with a Select List.
A RadioSet
is initialized with a locator for any of the constituent radio buttons.
When the name
value is the same between radio buttons, the RadioSet
initialized
by their locators will be the same:
A RadioSet
:
- Can be iterated over
- Returns currently selected radio button with
#selected
- Returns text and value of the selected radio button with
#text
and#value
- Returns whether the radio button with the provided label/text is
currently selected with
#selected?(#{label})
- Selects the radio button with the specified label/text with:
#select(#{label})
Selecting drop down options
Select#select_value
has been deprecated. Select#select
will now allow users
to locate elements by text, label or value. Having one primary way to select
options both matches the original Watir implementation as well as making it
easier to support automatic form filling methods in Page Object libraries.
Input Label
Sometimes a user might want to click on the label of an input element instead of the
element itself. With the new Input#label
, a user can now do:
See the Changelog for the complete history of updates.