Reputation: 27
I have a UWP application and I'm using CodedUI for UWP
It contains a report which is created as a ListView, and I need to verify some values in this list. But when I try to use the cross hair tool to drag it on the row or the list, the application keeps hanging, and when I succeeded in capturing the row then I ran the test case it failed because Codedui couldn't find the control.
In the attached photo I can capture Home tab button and other tabs and the drop downs and the buttons below it only, but If I drag the cross hair tool on the list it keeps hanging the application until I close it
what visualstudio captured for the listitem row
After running getchildren for the main window and then getparents hierarchy for the listitem control this is how they look like
Upvotes: 0
Views: 151
Reputation: 794
I possibly have a alternative to your problem. Below code will take a parent control and sift trough it until all children are added in a recursive way, respecting the control hierarchy. That way, you will have all available listview items at runtime. Control not found exceptions shouldn't be a issue here if you keep the KeyValuePair up-to-date whenever the listview item collection changes.
Use this recursive method:
public ParentControl GetChildControls(UITestControl parentControl)
{
ParentControl parent = new ParentControl();
if (parentControl != null)
{
List<ParentControl> children = new List<ParentControl>();
foreach (UITestControl childControl in parentControl.GetChildren())
{
children.Add(GetChildControls(childControl));
}
parent.Children = new KeyValuePair<UITestControl, List<ParentControl>>(parentControl, children);
}
return parent;
}
The ParentControl object:
public class ParentControl
{
public KeyValuePair<UITestControl, List<ParentControl>> Children { get; set; }
public string Value
{
get
{
return Children.Key.Name;
}
}
}
The Children property is mandatory , other properties are optional.
Upvotes: 1