-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table#rows #40
Table#rows #40
Changes from all commits
8e264bf
d94df4a
17fe691
32b667e
ec26c2a
418985a
55b9ad2
f712261
bebe7cd
0f08348
964a9a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,53 @@ | ||
module RAutomation | ||
module Adapter | ||
module MsUia | ||
class Row | ||
include Locators | ||
|
||
def initialize(window, locators) | ||
@hwnd = window.hwnd | ||
@locators = extract(locators) | ||
end | ||
|
||
def index | ||
@locators[:index] || 0 | ||
end | ||
|
||
def value | ||
UiaDll::row_value_at @hwnd, @locators[:index] | ||
end | ||
|
||
def exists? | ||
UiaDll::data_item_exists_by_index(@hwnd, @locators[:index]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is #exists? working with other locators than :index? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, currently it only works with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, right. |
||
end | ||
|
||
alias_method :text, :value | ||
alias_method :row, :index | ||
end | ||
|
||
class Table < Control | ||
include WaitHelper | ||
include Locators | ||
extend ElementCollections | ||
|
||
has_many :rows | ||
|
||
def row(locators={}) | ||
rows(locators).first | ||
end | ||
|
||
def rows(locators={}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 I will make that change |
||
Rows.new(self, locators).select do |row| | ||
locators_match? locators, row | ||
end | ||
end | ||
|
||
def locators_match?(locators, row) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After looking at the code again, I now remember why I did it this way. I did actually add the ability to filter by both text and by RegEx, but I did now know how to get this to work unless I retrieved all of the rows from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, what this Can't you do something similar? Instead of doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, but as soon as it finds one that does not match at all it quits. If you were doing a
It would only find the first one (rather than the 1st and the 3rd), correct? I'm sorry if I'm being obtuse about this, I just didn't know how to get this to check all of them, and not quit once something did not match. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since i do not know the inner workings of UiaDll, then can't you just retrieve all the data item controls and then perform the matching at Ruby side one by one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's exactly what this is doing. Rows.new(self, locators) If you specified an Rows.new(self, locators).select { |row| match_all_other_locators_besides_index?(row, locators) } There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just don't like the fact that Rows.new is used inside of Row. I'd like if that would work like other Controls - i can imagine that this would be only possible if somehow uiadll would return a collection of all rows which can be iterated later on. In that case the solution i'm looking for would work. Nevertheless - i'm merging this now, maybe you or someone else who knows these things technically can come up with better solution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you were happy with only supporting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you imagine any other possible locator for this kind of controls which would actually make sense? If not, then Anyway, merged changes in for now, so let's iterate in the future :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
locators.all? do |locator, value| | ||
return row.value =~ value if value.is_a? Regexp | ||
return row.send(locator) == value | ||
end | ||
end | ||
|
||
def strings | ||
rows = [] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As i understand then subclassing
Control
in this case wouldn't work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
Row
be aControl
?SelectList::SelectListOption
is not aControl
. Should this be different?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, see if there's anything you could reuse from
Control
. It doesn't have to be that, but if it makes sense then i don't see any reason, why not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I'll check into it. I most likely won't get to it until midnight tonight (I'm -5 GMT).