コード例 #1
0
        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();
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        public static void SetUIAItemControlValue(string name, string type, string value, WinWindow parent)
        {
            WinWindow itemWindow = new WinWindow(parent);
            itemWindow.SearchProperties.Add(new PropertyExpression(WinWindow.PropertyNames.ClassName, "HwndWrapper", PropertyExpressionOperator.Contains));
            itemWindow.WaitForControlReady();
            WpfPane pane = new WpfPane(itemWindow);
            WpfCustom customControl = new WpfCustom(pane);
            customControl.SearchProperties[WpfControl.PropertyNames.ClassName] = "Uia.SegmentedEntry";
            customControl.WaitForControlReady();
            WpfControl uIControl = new WpfControl(customControl);
            uIControl.TechnologyName = "UIA";
            uIControl.SearchProperties.Add("ControlType", type);
            uIControl.SearchProperties.Add("AutomationId", name);
            uIControl.WaitForControlReady();

            if (type == "CheckBox")
            {
                WpfCheckBox mUICheckBox = new WpfCheckBox(uIControl);
                mUICheckBox.Checked = Convert.ToBoolean(value);
            }
            else if (type == "Edit")
            {
                WpfEdit mUIEdit = new WpfEdit(uIControl);
                mUIEdit.Text = value;
            }
        }