Yes, it should show the correct index. Care to create an issue for it in JIRA?
Jarmo On Sep 1, 3:39 pm, brettsykes <[email protected]> wrote: > Thanks Michael. I grabbed the latest source from github with Jarmo's > fix and re-ran my test. It looks good and fixed! I still find it a > little strange however, that when I inspect the TableRow element, it > has this default value of how={:index=>0} ( #<Watir::TableRow: > 0x4e30450 located=true how={:index=>0} what=nil> ) when it should be > an index of 2. I understand that because I did not specify an index > that this gets put in there for me. However, I think this could get > confusing if someone is trying to debug an issue. Thoughts? > > Brett > > On Aug 31, 10:50 pm, Michael <[email protected]> wrote: > > > > > > > > > That bug is captured in:http://jira.openqa.org/browse/WTR-486 > > > And fixed in > > commit:https://github.com/bret/watir/commit/3846b6f300f5210df6b196eeeb15684b... > > You should see it in the next patch release. > > > There is another discussion post about it titled "watir 2.0.1 table rows > > method broken" that has a workaround. > > > On 2011-08-31, at 3:02 PM, brettsykes wrote: > > > > Ruby Version: 1.8.7 > > > WATIR Version: 2.0.1 > > > OS: Win 7 > > > > So I came across this issue as I just upgraded to 2.0.1. Basically, > > > when i get a TableRow object using the [] method, and then try to get > > > the text value from it, it always returns the text of the row with > > > index of zero. > > > > Steps to reproduce: > > > 1) HTML > > > > <html> > > > <table id="a_table"> > > > <tr><td>boring text</tr></td> > > > <tr><td>great text</td></tr> > > > <tr><td>the best text ever<td></tr> > > > </table> > > > </html> > > > > 2) Code > > > > #------------------------ > > > require 'rubygems' > > > gem 'watir', '=2.0.1' > > > require 'watir' > > > > b = Watir::IE.new > > > b.goto 'http://localhost/test.html' > > > > #get the third table row with text 'the best text ever' > > > table = b.table(:id, 'a_table') > > > row = table.rows[2] > > > > #the TableRow object has the correct ole_object stored within it > > > #before we call row.text > > > puts row.ole_object.invoke('innerHTML') > > > > #trying to get the text unfortunately outputs the text from row 0: > > > 'boring text' > > > puts row.text > > > > #now the TableRow object has the wrong ole_object in it > > > puts row.ole_object.invoke('innerHTML') > > > > #it looks like this happens because our TableRow object is using an > > > index of zero and not two > > > puts row.inspect > > > #------------------------ > > > > 3) Summary > > > > So, I read through some of the code, and it looks like this is > > > happening because when we call > > > table.row[2], our each method in elements_collection.rb doesn't pass > > > on any index information to > > > tagged_element_locator in container.rb. So, when we call set_specifier > > > inside tagged_element_locator, we set a > > > default value to an index of zero. Later on when we call row.text, > > > it's locate method thinks we are looking > > > for the row with an index of zero and not two. It then sets our > > > ole_object in the TableRow object to the zero index value. > > > > Brett > > > > -- > > > Before posting, please readhttp://watir.com/support. In short: search > > > before you ask, be nice. > > > > [email protected] > > >http://groups.google.com/group/watir-general > > > [email protected] -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected]
