コード例 #1
0
        internal ActionResult GetPropertyValue(AutomationElement automationElement, AutomationProperty automationProperty)
        {
            ActionResult actionResult  = new ActionResult();
            object       selectedValue = automationElement.GetCurrentPropertyValue(automationProperty);

            if (selectedValue != null)
            {
                actionResult.outputValue   = Convert.ToString(selectedValue);
                actionResult.executionInfo = "Succesfully retrieved the " + automationProperty.ToString() + " property value";
            }
            else
            {
                actionResult.errorMessage = "Failed to retrieve the " + automationProperty.ToString() + "  property";
            }
            return(actionResult);
        }
コード例 #2
0
ファイル: AppUnderTest.cs プロジェクト: Gnail-nehc/Black
        public AutomationElement FindDescendant(AutomationProperty searchBy, object value, AutomationElement retrieveControl = null)
        {
            var ret = GetControlTileEnable(searchBy, value, true, 30, retrieveControl);

            if (ret != null)
            {
                return(ret);
            }
            else
            {
                throw new ControlNotFoundException(searchBy.ToString() + ":" + value.ToString());
            }
        }
コード例 #3
0
ファイル: AppUnderTest.cs プロジェクト: Gnail-nehc/Black
        public AutomationElementCollection FindChildren(AutomationProperty searchBy, object value, AutomationElement retrieveControl = null)
        {
            var ret = GetControlsTileEnable(searchBy, value, false, 30, retrieveControl);

            if (ret != null)
            {
                return(ret);
            }
            else
            {
                throw new ControlNotFoundException(searchBy.ToString() + ":" + value.ToString());
            }
        }
コード例 #4
0
        internal static UIProperty Get(AutomationProperty property)
        {
            lock (lockObject) {
                if (_automationPropertyTable == null)
                {
                    _automationPropertyTable = new Dictionary <AutomationProperty, UIProperty>(capacity: _propertyTable.Count);
                    foreach (var uiProperty in _propertyTable.Values)
                    {
                        _automationPropertyTable.Add(key: uiProperty.Property, value: uiProperty);
                    }
                }
            }

            try {
                return(_automationPropertyTable[key : property]);
            } catch (KeyNotFoundException ex) {
                throw new UIQueryException(message: StringResource.Get(id: "PropertyNotFound_1", (object)property.ToString()));
            }
        }
コード例 #5
0
 private static string GetProgrammaticName(AutomationProperty prop)
 {
     if (prop == AEIds.AcceleratorKeyProperty)
     {
         return("AcceleratorKeyProperty");
     }
     else if (prop == AEIds.AccessKeyProperty)
     {
         return("AccessKeyProperty");
     }
     else if (prop == AEIds.AutomationIdProperty)
     {
         return("AutomationIdProperty");
     }
     else if (prop == AEIds.BoundingRectangleProperty)
     {
         return("BoundingRectangleProperty");
     }
     else if (prop == AEIds.ClassNameProperty)
     {
         return("ClassNameProperty");
     }
     else if (prop == AEIds.ClickablePointProperty)
     {
         return("ClickablePointProperty");
     }
     else if (prop == AEIds.ControlTypeProperty)
     {
         return("ControlTypeProperty");
     }
     else if (prop == AEIds.HasKeyboardFocusProperty)
     {
         return("HasKeyboardFocusProperty");
     }
     else if (prop == AEIds.HelpTextProperty)
     {
         return("HelpTextProperty");
     }
     else if (prop == AEIds.IsContentElementProperty)
     {
         return("IsContentElementProperty");
     }
     else if (prop == AEIds.IsControlElementProperty)
     {
         return("IsControlElementProperty");
     }
     else if (prop == AEIds.IsEnabledProperty)
     {
         return("IsEnabledProperty");
     }
     else if (prop == AEIds.IsKeyboardFocusableProperty)
     {
         return("IsKeyboardFocusableProperty");
     }
     else if (prop == AEIds.IsOffscreenProperty)
     {
         return("IsOffscreenProperty");
     }
     else if (prop == AEIds.IsPasswordProperty)
     {
         return("IsPasswordProperty");
     }
     else if (prop == AEIds.IsRequiredForFormProperty)
     {
         return("IsRequiredForFormProperty");
     }
     else if (prop == AEIds.ItemStatusProperty)
     {
         return("ItemStatusProperty");
     }
     else if (prop == AEIds.ItemTypeProperty)
     {
         return("ItemTypeProperty");
     }
     else if (prop == AEIds.LabeledByProperty)
     {
         return("LabeledByProperty");
     }
     else if (prop == AEIds.LocalizedControlTypeProperty)
     {
         return("LocalizedControlTypeProperty");
     }
     else if (prop == AEIds.NameProperty)
     {
         return("NameProperty");
     }
     else if (prop == AEIds.OrientationProperty)
     {
         return("OrientationProperty");
     }
     else if (prop == DockPatternIdentifiers.DockPositionProperty)
     {
         return("DockPatternIdentifiers.DockPositionProperty");
     }
     else if (prop == ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty)
     {
         return("ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty");
     }
     else if (prop == GridItemPatternIdentifiers.ColumnProperty)
     {
         return("GridItemPatternIdentifiers.ColumnProperty");
     }
     else if (prop == GridItemPatternIdentifiers.ColumnSpanProperty)
     {
         return("GridItemPatternIdentifiers.ColumnSpanProperty");
     }
     else if (prop == GridItemPatternIdentifiers.ContainingGridProperty)
     {
         return("GridItemPatternIdentifiers.ContainingGridProperty");
     }
     else if (prop == GridItemPatternIdentifiers.RowProperty)
     {
         return("GridItemPatternIdentifiers.RowProperty");
     }
     else if (prop == GridItemPatternIdentifiers.RowSpanProperty)
     {
         return("GridItemPatternIdentifiers.RowSpanProperty");
     }
     else if (prop == GridPatternIdentifiers.ColumnCountProperty)
     {
         return("GridPatternIdentifiers.ColumnCountProperty");
     }
     else if (prop == GridPatternIdentifiers.RowCountProperty)
     {
         return("GridPatternIdentifiers.RowCountProperty");
     }
     else if (prop == MultipleViewPatternIdentifiers.CurrentViewProperty)
     {
         return("MultipleViewPatternIdentifiers.CurrentViewProperty");
     }
     else if (prop == MultipleViewPatternIdentifiers.SupportedViewsProperty)
     {
         return("MultipleViewPatternIdentifiers.SupportedViewsProperty");
     }
     else if (prop == RangeValuePatternIdentifiers.IsReadOnlyProperty)
     {
         return("RangeValuePatternIdentifiers.IsReadOnlyProperty");
     }
     else if (prop == RangeValuePatternIdentifiers.LargeChangeProperty)
     {
         return("RangeValuePatternIdentifiers.LargeChangeProperty");
     }
     else if (prop == RangeValuePatternIdentifiers.MaximumProperty)
     {
         return("RangeValuePatternIdentifiers.MaximumProperty");
     }
     else if (prop == RangeValuePatternIdentifiers.MinimumProperty)
     {
         return("RangeValuePatternIdentifiers.MinimumProperty");
     }
     else if (prop == RangeValuePatternIdentifiers.SmallChangeProperty)
     {
         return("RangeValuePatternIdentifiers.SmallChangeProperty");
     }
     else if (prop == RangeValuePatternIdentifiers.ValueProperty)
     {
         return("RangeValuePatternIdentifiers.ValueProperty");
     }
     else if (prop == ScrollPatternIdentifiers.HorizontallyScrollableProperty)
     {
         return("ScrollPatternIdentifiers.HorizontallyScrollableProperty");
     }
     else if (prop == ScrollPatternIdentifiers.HorizontalScrollPercentProperty)
     {
         return("ScrollPatternIdentifiers.HorizontalScrollPercentProperty");
     }
     else if (prop == ScrollPatternIdentifiers.HorizontalViewSizeProperty)
     {
         return("ScrollPatternIdentifiers.HorizontalViewSizeProperty");
     }
     else if (prop == ScrollPatternIdentifiers.VerticallyScrollableProperty)
     {
         return("ScrollPatternIdentifiers.VerticallyScrollableProperty");
     }
     else if (prop == ScrollPatternIdentifiers.VerticalScrollPercentProperty)
     {
         return("ScrollPatternIdentifiers.VerticalScrollPercentProperty");
     }
     else if (prop == ScrollPatternIdentifiers.VerticalViewSizeProperty)
     {
         return("ScrollPatternIdentifiers.VerticalViewSizeProperty");
     }
     else if (prop == SelectionItemPatternIdentifiers.IsSelectedProperty)
     {
         return("SelectionItemPatternIdentifiers.IsSelectedProperty");
     }
     else if (prop == SelectionItemPatternIdentifiers.SelectionContainerProperty)
     {
         return("SelectionItemPatternIdentifiers.SelectionContainerProperty");
     }
     else if (prop == SelectionPatternIdentifiers.CanSelectMultipleProperty)
     {
         return("SelectionPatternIdentifiers.CanSelectMultipleProperty");
     }
     else if (prop == SelectionPatternIdentifiers.IsSelectionRequiredProperty)
     {
         return("SelectionPatternIdentifiers.IsSelectionRequiredProperty");
     }
     else if (prop == SelectionPatternIdentifiers.SelectionProperty)
     {
         return("SelectionPatternIdentifiers.SelectionProperty");
     }
     else if (prop == TableItemPatternIdentifiers.ColumnHeaderItemsProperty)
     {
         return("TableItemPatternIdentifiers.ColumnHeaderItemsProperty");
     }
     else if (prop == TableItemPatternIdentifiers.RowHeaderItemsProperty)
     {
         return("TableItemPatternIdentifiers.RowHeaderItemsProperty");
     }
     else if (prop == TablePatternIdentifiers.ColumnHeadersProperty)
     {
         return("TablePatternIdentifiers.ColumnHeadersProperty");
     }
     else if (prop == TablePatternIdentifiers.RowHeadersProperty)
     {
         return("TablePatternIdentifiers.RowHeadersProperty");
     }
     else if (prop == TablePatternIdentifiers.RowOrColumnMajorProperty)
     {
         return("TablePatternIdentifiers.RowOrColumnMajorProperty");
     }
     else if (prop == TogglePatternIdentifiers.ToggleStateProperty)
     {
         return("TogglePatternIdentifiers.ToggleStateProperty");
     }
     else if (prop == TransformPatternIdentifiers.CanMoveProperty)
     {
         return("TransformPatternIdentifiers.CanMoveProperty");
     }
     else if (prop == TransformPatternIdentifiers.CanResizeProperty)
     {
         return("TransformPatternIdentifiers.CanResizeProperty");
     }
     else if (prop == TransformPatternIdentifiers.CanRotateProperty)
     {
         return("TransformPatternIdentifiers.CanRotateProperty");
     }
     else if (prop == ValuePatternIdentifiers.IsReadOnlyProperty)
     {
         return("ValuePatternIdentifiers.IsReadOnlyProperty");
     }
     else if (prop == ValuePatternIdentifiers.ValueProperty)
     {
         return("ValuePatternIdentifiers.ValueProperty");
     }
     else if (prop == WindowPatternIdentifiers.CanMaximizeProperty)
     {
         return("WindowPatternIdentifiers.CanMaximizeProperty");
     }
     else if (prop == WindowPatternIdentifiers.CanMinimizeProperty)
     {
         return("WindowPatternIdentifiers.CanMinimizeProperty");
     }
     else if (prop == WindowPatternIdentifiers.IsModalProperty)
     {
         return("WindowPatternIdentifiers.IsModalProperty");
     }
     else if (prop == WindowPatternIdentifiers.IsTopmostProperty)
     {
         return("WindowPatternIdentifiers.IsTopmostProperty");
     }
     else if (prop == WindowPatternIdentifiers.WindowInteractionStateProperty)
     {
         return("WindowPatternIdentifiers.WindowInteractionStateProperty");
     }
     else if (prop == WindowPatternIdentifiers.WindowVisualStateProperty)
     {
         return("WindowPatternIdentifiers.WindowVisualStateProperty");
     }
     else
     {
         return(prop.ToString());
     }
 }
コード例 #6
0
        public BaseElement(BaseWindow baseWindow, AutomationProperty autProperty, string automationPropValue)
        {
            int ct = 0;

            do
            {
                element = baseWindow.GetAutomationElement().FindFirst(TreeScope.Descendants, new PropertyCondition(autProperty, automationPropValue));
                ct++;
                Thread.Sleep(100);
            } while (element == null && ct < 50);

            if (element == null)
            {
                throw new Exception(String.Format("Element was not found. Automation Property: {0} , Value: {1}", autProperty.ToString(), automationPropValue));
            }
        }