1
votes

Background: Am just learning Coded UI. This is from a simple test app in WPF using VS 12.

I have created a Coded UI Test Project and a Coded UI Test.

I have recorded opening the app, clicking a button, and then closing the app and it will run through this in a Test Run.

Now I want to add an assertion to a Treeview. The scenario is a user opens a file, and it loads a treeview, and I want to make sure the Treeview has at least one item in it.

So I run the exe, open the Coded UI Test Builder and drag the crosshairs to the Treeview. It successfully hightlights the TreeView. It then shows the Add Assertions Dialog.

The Treeview is shown in the Dialog, but there is no "Control Specific" properties of ItemsSource. It shows only 5 control specific properties, such as HelpText, AccessKey etc.

I can add an assertion for HelpText, but that isn't what is needed.

So the question, why isn't ItemsSource being shown in the Assertion Dialog?

How do I get it to show?

1

1 Answers

0
votes

After dragging the crosshairs tool onto a UI control the assertions dialogue is shown. To the right of the Add Assertion button there are four arrows arranged as Up, Down, Left and Right. Clicking these allow the selected control to be changed between siblings (Left and Right), ancestors (Up) and children (Down). Use these buttons to explore the tree control. I do not know what an "ItemsSource" is in the particular tree that you are viewing, it might not be an exposed property of the tree even if it is part of the implementation or the API. There may be other properties of some part of the tree that have the values you need.

I do not believe that Coded UI can generate an assertion to test that the tree contains at least one item. I believe you will need to hand code that part. My first thoughts there would be to get the UIControl object for the tree and then use its GetChildren method to find the items in the tree. That may need to be recursive to get all the elements in the tree.