Hello.

I have exchanged some e-mails with Jari recently about Watir WebDriver
(and Watir 2.0) and have come up with at least
three proposals, which would change the current API a little by making
tests better, thus I would bring them up in here also.

Feel free to express yourself :)

1) Default locator for all elements should be :index => 0

I'm finding myself very often clicking links on the table with random
identifiers. Consider a table like this:

<table id="table_id">
 <tr>
   <td>Something</td>
   <td><a href="#" onclick=delete(somerandomid)>Delete</a></td>
 </tr>
 <tr>
   <td>Something else</td>
   <td><a href="#" onclick=delete(somerandomid)>Delete</a></td>
 </tr>
</table>

Now, if i want to delete "Something else", then
currently i have to do something like this:

product = b.table(:id => "table_id").rows.find {|row| row.text ==
"Something else"}
product.link(:index => 1).click

With my proposal it would be like this:
product = b.table(:id => "table_id").rows.find {|row| row.text ==
"Something else"}
product.link.click

And with the possibility (from Google Wave about Watir 2.0 by Jari) to
use locators for collections:
product = b.table(:id => "table_id").trs(:text => "Something else").first
product.link.click



2) Selenium has a lot of different ways of locating elements. This is
not what i would like to see in
Watir and as i understand then most of you in here also think like
that. But i think that it would
be great if ALL elements would accept one String as an identifier,
which would be used to locate an
element first by id and then by name. No exceptions - it would be the
same for every element.

For example:
b.text_field("blah").set "my text" # would search text fields with ID
and if not found then by NAME and if still not found
                                   # would raise exception

I'm asking this because most of the time i have to use ID or NAME (in
that order) to locate
elements, which means that my tests are full of method(:id => 'xxxx')
and method(:name => 'sfdas'). Would be great if there would be
less code.

Wouldn't it make sense to add this functionality then?



3) Allow only hash syntax for element locators (+ String in proposal
#2). So, text_field(:id, 'sfdsa') is not allowed anymore. Why?
Well, it's again to have less syntax for finding elements and you can
use only hash when using multiple identifiers anyway.
Especially newcomers might get confused if at one place they read
text_field(:id => 'sfdsa') and other place comma
is used.

I think that since it is going to be a major release then some
backwards incompatibilities are allowed, no?


Jarmo
_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development

Reply via email to