Watir 6.0 Beta 5 is now available on rubygems! Watir 6.0 depends on Selenium 3.0, and it will have its production release once Selenium 3 is released. We’re continuing to update and simplify the code in the meantime. This release allows elements in collections to be relocated when stale, adds a new visibility locator, and provides updated error messages when unable to locate elements.
or in your Gemfile:
Relocating Elements from Collections
This new feature addresses one of the most common confusions people have with Watir. Watir now allows things like iterating over a collection of elements, even when the DOM changes:
Note - the above code is for example only, it is not the recommended way to verify working links.
The above code would previously have provided this not-very-helpful error message:
As Single Page Apps become more common, there are often multiple similar forms that exist on the page at the same time, while only one of them is visible. For instance, a create object modal and an edit object modal, or a log in modal and a sign up modal. Rather than needing to create multiple page objects if the forms have the same characteristics, or needing to use index locator to pick which form to use, Watir now supports locating based on a visible locator:
If there are multiple forms with the a name attribute of “username”, this locator will return the first one that is visible on the page.
Previously, error messages for when elements were not found only returned selector information for the most nested element. For instance, if this iframe was present, but the div inside it was not, this used to be the result:
To provide more information on the exact problem, the error will now look like this:
See the Changelog for a complete list of updates.