0

I am doing a UI automation for a WPF application using the Microsoft UI Automation library and it works well.

However my app has four screens in a TabControl. Even when I click the tab item through code its child control tree isnt populated. The only control I can see is the "thumb" Control. Same happens when I see the control tree with UISpy.

However if the window is clicked then all the controls appear. As a Workaround I am simulating a mouseclick through code and it works. I wanted to know if there is some better way of doing it.

ganeshran
  • 3,512
  • 7
  • 41
  • 69
  • Do you mean activating the window causes the controls to be drawn ? – Gishu Jul 28 '11 at 09:35
  • ya controls are drawn only after the window is clicked. Till then I am not able to see the control tree even in UI spy. Is there a way to force the control to refresh itself? – ganeshran Jul 28 '11 at 14:00
  • why isn't the window activated *before* you try to manipulate controls via automation? In some cases, the controls are not rendered unless they are visible - optimization. Not sure if that's what you're seeing. I usually make my main window maximized and active to begin with. – Gishu Jul 29 '11 at 05:17
  • I am able to see the controls. But UI automation library is not able to see them till I click on it once. Even UI Spy doesnt show the controls till they are clicked. The only child of the tab is the "Thumb" control. But once i click it, all children become visible both to UI Automation and UISpy – ganeshran Jul 29 '11 at 06:00
  • strange. Maybe you could create a small sample app that reproes this so that people can investigate. – Gishu Jul 29 '11 at 07:21
  • Check this link:http://stackoverflow.com/questions/37312410/wpf-user-control-cannot-be-seen-in-inspect – Newton Zou May 19 '16 at 01:17

2 Answers2

0

I ran into a problem similar to this. What was happening was some data was being retrieved on threads and the controls were not generated at the point automation peers were generated. I would suggest if you have access to the code base for the application you are attempting to automate looking into whether threading is being used. In my specific case it was because BeginInvokes were used to retrieve the data, I switched them to Invokes and it worked fine.

Also from what I could tell the reason the controls were being show on mouse over was because the tool tip generated a popup and caused the automation peers to be updated.

Max Young
  • 1,522
  • 1
  • 16
  • 42
-1

Why don't you click the control using mouse events if that is what works.

(Now, if you still are having that problem..)

How to simulate Mouse Click in C#?

Community
  • 1
  • 1
Andreas Reiff
  • 7,961
  • 10
  • 50
  • 104