jarmo / RAutomation

RAutomation
MIT License
100 stars 33 forks source link

Not able to identify and click on the elements of Tree Structure #82

Closed Amit1986 closed 10 years ago

Amit1986 commented 10 years ago

Hi All,

I have some queries regarding the use of adapters of RAutomation:

1) Can the adapters of RAutomation(ms_uia or win32) be used to identify Java Objects on SWT Windows(:class => "SWT_Window0") and perform actions on it?

2) I have a tree structure(attaching the screenshot), there are many folders in the tree structure. I would like to identify those folders and able to expand or collapse. Would these be done with the above adapters. The class of this tree is "SysTreeView32".

3) I have some tabs in a :class => "SWT_Window0" but not able to identify these tabs using the AutoIt tool. Can these tabs still be identified and get clicked? I am attaching the screenshot for the same. tabs tree structure

leviwilson commented 10 years ago

1) Can the adapters of RAutomation(ms_uia or win32) be used to identify Java Objects on SWT Windows(:class => "SWT_Window0") and perform actions on it?

For :ms_uia you would have to use a tool like UISpy or UIAutomationVerify to determine if you are able to see the hierarchy of controls in a Java SWT application. For :win_32 you would have to look at Spy++ to determine what you will be able to work with.

2) I have a tree structure(attaching the screenshot), there are many folders in the tree structure. I would like to identify those folders and able to expand or collapse. Would these be done with the above adapters. The class of this tree is "SysTreeView32".

:ms_uia can work with SysTreeView32 controls. If items are not expanded, sometimes it will not see the children until their parents are expanded. Other than that, it should be fine. Again ,refer to what UISpy says.

I can't recall how much you are able to do with TreeView controls with :win32.

3) I have some tabs in a :class => "SWT_Window0" but not able to identify these tabs using the AutoIt tool. Can these tabs still be identified and get clicked? I am attaching the screenshot for the same.

:ms_uia can work with tab controls as well.

brahmanand012 commented 10 years ago

I am getting the same problem regarding the selection of differnt div in the table..

leviwilson commented 10 years ago

With which adapter? Can you post your sample app on DropBox or something so I can take a look at, as well as the code that you are using to try to automate it?

Amit1986 commented 10 years ago

Hi Levi, Thanks for the reply. If you have some sample code ready for identifying the tabs and select a particular tab, please share it with me. It will be Helpful and highly appreciated.

Thanks in advance.

leviwilson commented 10 years ago

For samples of working with any of the code, please check out the specs for RAutomation. There is a sample application that it uses for the tests that should give a clear example of how to use them.

Amit1986 commented 10 years ago

Hi Levi,

I am providing you the screenshot of the application and the UISpy Screenshot of the element as well. In this screenshot we have selected "LoadTestMMX37" in the tree structure and for the same we are providing the screenshot of UISpy. application uispy for app

Amit1986 commented 10 years ago

To be more Descriptive: When I am trying to select the tab "Impact Analysis" in the image above with the following code I am receiving an error:

window = RAutomation::Window.new(:title => /My Application/ ,:adapter =>"ms_uia") window.activate window.active? window.exists? # => true

window.title window.text

new_ctrl = window.tab_control(:class => "SWT_Window0")

puts new_ctrl.items.to_s new_ctrl.select(6) ############################################################################# Output: Output of new_ctrl.items.to_s is "[#<RAutomation::Adapter::MsUia::TabControl::TabItem:0x1a4f0cd @text=\"Overview\", @index=0, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0xfe64c3 @text=\"Related Datasets\", @index=1, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0x1895756 @text=\"Audit Logs\", @index=2, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0x1c4d60b @text=\"Change History\", @index=3, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0x1c086ba @text=\"Summary\", @index=4, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0xcd3e08 @text=\"Details\", @index=5, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0xa3bd2d @text=\"Impact Analysis\", @index=6, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0x1d90c0d @text=\"Viewer\", @index=7, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0xa63bdd @text=\"JT Preview\", @index=8, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0x1a46b20 @text=\"Process History\", @index=9, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0x1752cc6 @text=\"Home\", @index=10, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>, #<RAutomation::Adapter::MsUia::TabControl::TabItem:0x1cea3eb @text=\"My Projects\", @index=11, @tab_control=#<RAutomation::Adapter::MsUia::TabControl:0x1bd4880 @cached_hwnd=0, @locators={:index=>0, :class=>\"SWT_Window0\"}, @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 @hwnd=133008, @locators={:index=>0, :title=>/My Application/}, @container=#<RAutomation::Window:0x17db906 @window=#<RAutomation::Adapter::MsUia::Window:0xd8b870 ...>, @adapter=\"ms_uia\">>>>]" ###########################################################################

However, When I am trying to set the tab "Impact Analysis" with index 6 is giving me an error that "RuntimeError: A tab with index 6 was not found".

Please help me on this.

Amit1986 commented 10 years ago

As we can see on the above tree structure that the elements of the Tree Structure are not showing In UISpy tool. So can you provide any input to automate this one.

leviwilson commented 10 years ago

The TreeView does not look like you'll be able to do a whole lot with any of the names, as it looks like the Java SWT is not reporting that to UI Automation (the "Name" property). I'm not sure about the tab one. As I mentioned earlier, if you threw together a sample app that did something similar, I would be able to check it out further. It's hard to tell from the screenshots.

Amit1986 commented 10 years ago

@leviwilson ,

I think the Java tree is picking the tree structure value at run time from the database. Cant we take any other property apart from name to identify those items of tree structure, or we have to take it from database for further process. Is there any other way. Please help me out. If I find any other application similar to this application or the trial version of this product, I will let you know and share it in DropBox.

leviwilson commented 10 years ago

Regardless of where it comes from, those properties do not reflect what the text value is. If you're not seeing it in UISpy it's not exposed to automation fully. There is no other way to get their values that I'm aware of.

brahmanand012 commented 10 years ago

@leviwilson, But even i get the index and the value of text ., i am not able to click or select that item. I have used function inside control_tab and control but still not able to select the tab element.

brahmanand012 commented 10 years ago

sorry it is tab_control not control_tab

Mandeep10 commented 10 years ago

How can we use Press_key and Release_key function? I have used window.press_key(:control), but it is showing error. [TypeError: can't convert Symbol into Integer]. Send_key function is working, in which Press_key and Release_key functions are used. Can you please explain?

leviwilson commented 10 years ago

@brahmanand012 the backend code that tries to select a Tab in a TabControl uses [the following logic]. To be able to select a tab, it has to be a child of the TabControl itself and the control type property has to be ControlType.TabItem. If that is not true, it wouldn't find it. If you're getting the text of it, this should probably be true.

Now, to select it, it is simply casting each TabItem as a control that implements the SelectionItemPattern and calling the Select method on it. If you right click on the element in UISpy and invoke the Select method directly, does it work? That would be pretty much exactly what the :ms_uia adapter would be doing in RAutomation.

leviwilson commented 10 years ago

Honestly guys, the best thing would be to get a sample app that has the same controls. It can be fake data in the tree, it doesn't matter. I can take a look at it. It's hard to surmise what is going on without seeing it.

Amit1986 commented 10 years ago

@leviwilson : Do you know any other UI tools that can identify java objects and can provide their maximum properties, so that I can use them in my automation.

leviwilson commented 10 years ago

I don't know of any other tools. If you cannot interact with it / identify elements with UISpy or Visual UI Verify, then it will not work out of the box for you. I'm closing this issue unless you think there is something wrong with the driver.