Friday, September 30, 2011

WATIR 2.0


Watir 2.0 got released recently. Here are some features in the newest version:


1. No FireWatir:
There won’t be any new releases of FireWatir due to the fact that JSSH extension, which is used to control Firefox by FireWatir, is not available for Firefox versions 4 and newer.


2. Zero based indexing:
Watir has used one based indexing so far but with 2.0 it is using Zero based indexing. If you are using Watir 1.x and you’d like to access first div element on the page, you’d write code like this:


browser.div(:index => 1)
In Watir 2.0 and newer, you have to write code like this instead:


browser.div(:index => 0)


3. Multiple locators:
All elements support multiple locators for searching. 
e.g. browser.span(:name => "something", :class => "else")


4. Default locator:
In other words – if no other locators are specified, then :index => 0 will be used as a default. for e.g.
browser.span(:class => "something").div(:index => 1).span(:class => "else")  //1.x
browser.span(:class => "something").div.span(:class => "else") //2.0


5. Aliased methods
In Watir 2.0 you can use #tr, #trs, #td, #tds, #a, #as, #img and #imgs instead of instead of browser.row, browser.td or browser.cell.

No comments:

Post a Comment