Watir 6.15 is now available on RubyGems. A few new element methods, new contributors, and some minor performance improvements. The equivalent functionality in Python has also been released in Nerodia 0.12.
or in your Gemfile:
to install Nerodia (Python)
For more information visit: https://github.com/watir/nerodia/blob/master/README.rst
- Thanks to Ryan Baumann for his contribution to our project
- Thanks also to Thomas Walpole from Capybara for helping us improve our Regular Expression matching
New Element Methods
Elements#selected_text: This is the reflexive method to
Stringof all of the classes for the given element with white space, it makes more sense to be able to return an
Arrayof class values if there are multiple classes expected.
Element#obscured?: The intent here is to evaluate whether
Element#clickwill result in a
ElementClickInterceptedErrorbefore having to make the click in the first place.
A major feature of Watir over using Selenium directly is the extended number of locators available. Watir
allows you to combine multiple locators to more accurately describe a unique element without needing to resort to
writing difficult to read (and likely brittle) XPath or CSS strings.
Watir takes a
Hash of locators and runs it through a
By default this is implementated with XPath.
This class will convert the provided
Hash into an ugly but accurate XPath locator that the end user thankfully never
needs to look at but is exactly what the driver needs to locate the element. Any locators that can not be
entirely converted into a single XPath expression (things pertaining to visibility, or values with complicated
Regular Expressions), the
Locator class will use whatever could be built into a partially matching XPath expression,
locate all elements that match it,
and then iterate through each of those elements attempting to match the remaining locators.
The new code in this version will locate more elements on the first try without requiring iteration,
and does a better job filtering out the number of elements that need to be iterated over when using complex
Tips on using
Regexp values in locators:
- Use only word characters: For instance
/random-/should be preferred when possible over more complex ways of matching, like:
- “Starts with” can also be entirely captured in one call, so you can do
/^random-/if that addition makes it unique
- If you need to use more anything more complicated, make it as specific as possible to minimize the number of elements that need to be iterated over to find the exact element you are looking for.
See the Changelog for the complete history of updates.