jarmo / RAutomation

RAutomation
MIT License
100 stars 33 forks source link

Tables appear broken on the :ms_uia adapter #106

Closed samachr closed 7 years ago

samachr commented 8 years ago

I'm trying to access a table using ms_uia, and the code seems to support it. However, when actually working with it, it doesn't seem to work.

irb(main):021:0> w = RAutomation::Window.new :title => "Search", :adapter => :ms_uia => #<RAutomation::Window:0x3370878 @adapter=:ms_uia, @window=#<RAutomation::Adapter::MsUia::Window:0x33706c8 @container=#<RAutomation::Window:0x3370878 ...>, @locators={:index=>0, :title=>"Search"}>> irb(main):022:0> t=w.table :id => "dg_qbe" => #<RAutomation::Adapter::MsUia::Table:0x33ec328 @window=#<RAutomation::Adapter::MsUia::Window:0x33706c8 @container=#<RAutomation::Window:0x3370878 @adapter=:ms_uia, @window=#<RAutomation::Adapter::MsUia::Window:0x33706c8 ...>>, @locators={:index=>0, :title=>"Search"}, @hwnd=198454>, @locators={:index=>0, :id=>"dg_qbe"}> irb(main):023:0> t.exists? => false irb(main):024:0> t.visible? => true irb(main):025:0> t.rows System.InvalidOperationException: Unsupported Pattern. at System.Windows.Automation.AutomationElement.GetCurrentPattern(AutomationPattern pattern) at RAutomation.UIA.Controls.TableControl.get_RowCount() at Table_RowCount(_FindInformation* findInformation) => []

This is what the datagridview looks like. image

It seems to find the element and can even focus to it, but it doesn't support other operations. Am I misunderstanding the functionality?

leviwilson commented 8 years ago

Is it possible to get a screenshot of what UI Spy or Inspect say about the grid? The :ms_uia adapter cares specifically about certain patterns in order to report things correctly; if the grid control is not honoring / exposing some of these, it could be the issue you are seeing.

A screenshot of the tree of your grid control would be useful; also which patterns the row elements expose.

For a comparison, you could build the WindowsForms.sln project and see what the grids look like in Inspect for it?

samachr commented 7 years ago

It appears to be missing the correct invoke patterns. Sounds like it is on my side, not yours. Thanks for your help!