Unable to identify objects in WPF Winform10 application
See original GitHub issuePlatform: Window Server 2016 64 Bit Language: Python 2.7 IDE: Visual Studio Code pywinauto V0.6.6
I am attempting to automate a DotNet application. pywinauto appears to correctly find some windows and buttons(if I am very broad in defining the object properties) but I seam to be completely unable to identify TreeView’s. If there is a tree view on the page pretty much everything else can not be found either.
I have attached properties as identified by Microsoft SDK Inspect tool. The only object I can identify is the MainContextManagementPage using:
contextManagement = Application().connect(title_re="Context Management.*", timeout=20)
Using either backend="uia"
or backend="win32"
makes no difference to finding the other objects:
Using debugger I can see the code does not appear to identify any of the objects I am looking for:
TreeViewWrapper(pywinauto.findwindows.find_windows(best_match=u'TreeView',top_level_only=False)[0]) MatchError: Could not find 'TreeView' in '[u'', u'Chrome_WidgetWin_1', u'MSTaskSwWClass', u'Running applicationsMSTaskListWClass', u'User Promoted Notification AreaToolbar', u'TrayNotifyWnd', u'Start', u'Touch keyboard', u'Touch keyboardTIPBand', u'ApplicationFrameTitleBarWindow', u'8', u'5', u'Action Center', 'Toolbar2', u'FolderView', u'Context Management - HwndWrapper[BLAH.exe;;468c-b7f5-efb281f5f434]', u'ApplicationFrameWindow', u'Shell_TrayWnd', u'User Promoted Notification Area', u'MyLibrary.py - MyAutomation - Visual Studio Code [Administrator]', u'Action CenterButton', u'System Clock, 2:47 PM, \u200e5/\u200e20/\u200e2019TrayClockWClass', u'MyLibrary.py - MyAutomation - Visual Studio Code [Administrator]Shell_TrayWnd', u'Context Management', u'ApplicationFrameInputSinkWindow', u'1', u'0', u'3', u'2', u'Running applications', u'4', u'Program Manager', u'6', u'7', u'System Promoted Notification Area', u'System Promoted Notification AreaToolbar', 'ListView', u'Running applicationsMSTaskSwWClass', u'Program ManagerProgman', u'Running applications1', u'Running applications0', u'Windows Ink WorkspaceTrayNotifyWnd', 'ReBar', u'DummyDWMListenerWindow', u'HwndWrapper[DMD.exe;;cd7d7cb9-8684-468c-b7f5-efb281f5f434]', u'Action CenterButton2', u'Action CenterButton1', u'Windows Ink Workspace', u'Button', u'Button2', u'Button1', u'Search WindowsButton', u'EdgeUiInputTopWndClass', u'Button5', u'Button4', u'SHELLDLL_DefView', u'Task ViewButton', u'Toolbar0', u'Action CenterButton0', u'TIPBand', u'FolderViewListView', u'TrayClockWClass', u'Button3', u'MyLibrary.py - MyAutomation - Visual Studio Code [Administrator]Chrome_WidgetWin_1', u'Search Windows', u'Task View', 'Pager', u'Toolbar1', u'Running applications2', u'MSTaskListWClass', u'Button0', 'Toolbar', u'Task ViewReBar', u'Progman', u'System Clock, 2:47 PM, \u200e5/\u200e20/\u200e2019', u'StartStart', u'Windows Ink WorkspaceButton', u'Button6']'
Any help would be greatly appreciated. Using UFT(which I dont want to use) I can see the objects can be identified as expected.
Window("Program Manager").WinListView("SysListView32").Activate "APP"
SwfWindow("Configuration Selector").SwfButton("OK").Click
WpfWindow("Context Management").("contextTreeView").Select "RealTime;MYLINK);RealTime"
WpfWindow("Context Management").WpfButton("Connect to Context").Click
ButtonObjectProperties.txt MainContextManagementPageProperties.txt TreeViewItemObjectProperties.txt TreeViewObjectProperties.txt
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (8 by maintainers)
Thank you. Was great to see the draw_outline() in action. Yes I found your suggestion of: contextManagementWindow.child_window(auto_id=“id_RealTime1”, control_type=“TreeItem”).select() worked using the .select(). Unfortunately I found the auto_id would be difficult to predict with char replacement and duplication. I have however found a solution as per below: If you think there is anything I can do to simplify or fix please let me know. Thank you so much for the support.
I am not sure if there are any future changes that could be made to the framework to handle tree structures like this?
Ok, then try
desc.element_info.control_type
.