jarmo / RAutomation

RAutomation
MIT License
100 stars 33 forks source link

UIA table support for items and cells #38

Closed leviwilson closed 11 years ago

leviwilson commented 11 years ago

Introduced the ability to work with individual cell items in a table. Can get items (and their subitems / cells). This is dependent on pull request #37.

jarmo commented 11 years ago

I have few comments/questions for this:

1) Why is it called items and not rows? I'd prefer API similar to Watir if it's possible:

# Table would have rows
table.rows[0].value # => "John Doe"

# add an alias for #value as #text too
table.rows[0].text # => same as #value

# possible to specify locators like with every other control
table.rows(:value => /Doe/).size # => 2; "John Doe" and "Anna Doe" both match.

# access also single control
table.row(:value => /Doe/).text # => "John Doe"

# can be also done without locators like other controls, first one will be returned
table.row.text #=> "John Doe"

# can access cells
table.rows[0].cells.size #=> 3

# of course you can also provide locators and have #text as an alias
table.rows[0].cells(:value => "FL")[0].text # => "FL"

# you can also access single cell
table.rows[0].cell(:value => "FL").text # => "FL"

# also any reason why row/rows and cell/cells couldn't be made accessible directly on the window too? This means that there should be a Window#tables, which i'm not sure exists right now...
window.rows(:text => "something") # will find all rows on all tables, which match the locator

window.cells(:text => "something") # will find all cells on all tables, which match the locator

ElementCollections (https://github.com/jarmo/RAutomation/blob/master/lib/rautomation/element_collections.rb) might help you with creating support for plural methods rows/cells. There is an example at https://github.com/jarmo/RAutomation/blob/master/lib/rautomation/window.rb#L15 which is quite outdated :(

I think you get the point. Or is there any reason, why the API should be different?

2) #strings also use some kind of a rows. It should be possible to reuse your work if you've completed step 1, if i'm not mistaken. That would be awesome!

One way would be to split these things up and not make it as one large Pull request. I'd prefer that. So for example, one pull request would add Table#row(s), another one Table#cell(s) and yet another one Window#tables and then Window#row(s) and Window#cell(s). It would make reviewing your commits easier.

Anyway, i'm really thankful for your hard work so far and i'm hoping that my comments won't be a setback for you.

leviwilson commented 11 years ago

Not a setback at all, appreciate the feedback. I'm not that familiar with watir so I did not know what should have been idiomatic for the apis...that and I probably had more :beer: :beer: :beer: last night than I should have when submitting pull requests :-) I'll make the adjustments and also break these out into individual commits, not a problem. Thanks again for the feedback.

leviwilson commented 11 years ago

Also, apologies for the large commits...I wasn't sure if it would be easier this way, or multiple commits that were dependent upon each other.

jarmo commented 11 years ago

No problem, i meant that i'd like more separate pull requests (meaning of course more commits too) instead of one big with all the features. In that case they would be dependent on each other, which is not a problem, i guess.

leviwilson commented 11 years ago

But since they're dependent upon each other, the diff is still going to look the same to you is it not? I thought it always diff'd against jarmo:master?

jarmo commented 11 years ago

If i merge pull request 1 then pull request 2, which might have been dependant of pull request 1 has less diff against master at that moment.

leviwilson commented 11 years ago

Sounds good, I'll close this and issue pull requests separately.

jarmo commented 11 years ago

Thank You!