public void CodedUITestMethod1() { var mainWindow = GetMainWindow(); var btn = new WpfButton(mainWindow); btn.SearchProperties.Add(new PropertyExpression(WpfControl.PropertyNames.AutomationId, "btn_AddShape")); btn.Find(); btn.WaitForControlReady(); Mouse.Click(btn); var diagram = new WpfCustom(mainWindow); diagram.SearchProperties.Add(new PropertyExpression(WpfControl.PropertyNames.AutomationId, "diagram")); diagram.Find(); diagram.WaitForControlReady(); var element = new WpfCustom(diagram); element.SearchProperties.Add(new PropertyExpression(WpfControl.PropertyNames.AutomationId, "CustomElement_1")); element.Find(); element.WaitForControlReady(); var itemsControl = new WpfList(element); itemsControl.SearchProperties.Add(new PropertyExpression(WpfControl.PropertyNames.AutomationId, "itemsC")); //The CodedUI can't find the ItemsControl itemsControl.Find(); itemsControl.WaitForControlReady(); string[] s = itemsControl.Items.GetValuesOfControls(); }
public void CodedUITestMethod1() { var mainWindow = GetMainWindow(); var btn = new WpfButton(mainWindow); btn.SearchProperties.Add(new PropertyExpression(WpfControl.PropertyNames.AutomationId, "btn_AddShape")); btn.Find(); btn.WaitForControlReady(); Mouse.Click(btn); var diagram = new WpfCustom(mainWindow); diagram.SearchProperties.Add(new PropertyExpression(WpfControl.PropertyNames.AutomationId, "diagram")); diagram.Find(); diagram.WaitForControlReady(); var element = new WpfCustom(diagram); element.SearchProperties.Add(new PropertyExpression(WpfControl.PropertyNames.AutomationId, "CustomElement_1")); element.Find(); element.WaitForControlReady(); var itemsControl = new WpfList(element); itemsControl.SearchProperties.Add(new PropertyExpression(WpfControl.PropertyNames.AutomationId, "itemsC")); //The CodedUI can't find the ItemsControl itemsControl.Find(); itemsControl.WaitForControlReady(); var items = itemsControl.Items.OfType <WpfListItem>().ToArray(); string[] s = items.Select(x => x.AutomationId).ToArray(); s.Should().BeEquivalentTo("ItemA", "ItemB", "ItemC", "ItemD", "ItemE", "ItemF", "ItemG", "ItemH"); }