Hello, Bret. How do you see that #1 will cause compatibility problems? Do you mean 0-based indexing? This is done anyway already with Watir WebDriver (http://wiki.github.com/jarib/watir-webdriver/comparison-with-watir-1x) and i think that it is a really good thing. If you have that in mind, then default :index => won't bring any backwards compatibilities.
About #3 you might be correct, but i think that this is a one technical debt which would be great to get rid of before it's too late. Having backwards incompatibilities in mind i recommend to just deprecate it in Watir 2.0 and remove completely in some newer version. What if we issue Kernel.warn for every comma usage and show some message when executing b.text_field(:id, "blah"): *** Using 2 parameters as a element locator is DEPRECATED! Use at c:/projects/project/spec/some_file_spec.rb:45 this instead: text_field(:id => "blah") *** It might get messy at first if comma notation is used a lot, but it gives a possibility to clean things up and even to create some script which would analyze this log and do it for you automatically. What do you think about this or similar idea? When i think about technical debts, then it's not reasonable to have it forever due to the reason of not wanting to create backwards incompatibilities. Jarmo On Fri, May 7, 2010 at 7:28 PM, Bret Pettichord <[email protected]> wrote: > I've previously proposed both #1 and #3. In theory people like the idea. > But mostly people hate the idea of the compatibility problems these would > introduce. And looking at all the tests we have here at Convio, I see the > same problem. If these kinds of changes were made in Watir 2.0, we would not > be able to use it. > > Bret > > On Fri, May 7, 2010 at 10:42 AM, Jarmo <[email protected]> wrote: >> >> 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 > > > > -- > Bret Pettichord > Lead Developer, Watir, www.watir.com > > Blog, www.io.com/~wazmo/blog > Twitter, www.twitter.com/bpettichord > > > _______________________________________________ > Wtr-development mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/wtr-development > _______________________________________________ Wtr-development mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-development
