Recently I came to know from this article -
http://blogs.msdn.com/b/patrickdanino/archive/2009/11/11/custom-controls-and-ui-automation.aspx
-that controls in WPF are responsible for exposing their UIA items themselves, and any newly added functionalities of a custom control aren’t available to the UIA until they are exposed through the implementation of the corresponding AutomationPeer class. At my work I have been assigned to the automation of UI testing of a WPF application that employs a large number of ToolBars. The problem is, through Microsoft UI Automation Library I can access the ToolBars (apparently which are developed as custom control) as AutomationElements, but I cannot access the Buttons inside them – Count of Children/Descendant Collection always return 0. When using Coded UI Test, the tests always fail and shows the following Error Message:
Test method CAM2QDummyTest.CodedUITest2.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnBlockedControlException: Another control is blocking the control. Please make the blocked control visible and retry the action. Additional Details:
TechnologyName: 'MSAA'
Name: 'Standard'
ControlType: 'ToolBar'
---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0xF004F003
Apparently they didn’t implement the corresponding AutomationPeer classes. Now, I only have the application, not the source code. So I cannot solve the problem in the way described in the article I mentioned above. Can anyone HELP with any clue how can I get access to the inner Buttons of the ToolBars? Any suggestion will be gratefully appreciated.