1

My WPF application implements prism framework. There are few menu controls which get loaded to the container as the page changes. I am trying to use Coded UI, to add assertions to these buttons.

When CUIT is used on first screen, nothing seems to be recognized. But on second screen they get recognized. There is no change in the code for loading them except that the controls are one level deep on the first screen (that's what snoop shows).

Do I need to still have Automation peers code to be written at source code end to expose the controls though they are standard WPF controls?

What else can I try to get them recognized consistently?

Inspect.exe, UIA Verify, Snoop display all the WPF controls irrespective of the screen I am in.

7
  • Try adding Thread.Sleep() before loading the first screen Commented Apr 1, 2012 at 22:41
  • Thanks KMoraz, but I have no access to the dev code. And if Sleep was meant to be in the test code, can you please explain how it works. Commented Apr 2, 2012 at 8:03
  • It will allow waiting for all the controls to load Commented Apr 2, 2012 at 9:24
  • @KMoraz Thread.Sleep isn't recommended. If the controls aren't recognized because they need to wait to be loaded using PlayBack.Settings.WaitForReadyLevel set to wait for all threads will be much more effective/efficient but I doubt that is the actual problem here. Commented Apr 2, 2012 at 12:12
  • @kris123pra You didn't mention if you are hand writing the code or using the recording feature. If you are recording are the controls recognized in the UIMap editor? Commented Apr 2, 2012 at 12:33

1 Answer 1

2

Ok so I think I understand. When you go to the first page and try to highlight or select an item using the CodedUI Test Builder or Spy++ the controls are not recognized but they are recognized on a different page.

Is the container the controls are in on the first page some type of custom control or a generic WPF control? If it is a custom control you will need to implement AutomationPeer class to do meaningful actions on the control. If all you need to do is click a button you could hand write code to manually click within the parent container.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. The controls were standard WPF buttons. We found that there was another layer which was hindering the coded ui to recognize the controls. For now the issue is resolved, but was wondering if these kind of things happen again, it would be good to know how to implement Peers. Can anyone suggest good sites?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.