Esempio n. 1
0
        public void TestReadyStateProperty()
        {
            // Query our custom property
            var readyStateValue = _customElement.GetCurrentPropertyValue(ReadyStateSchema.GetInstance().ReadyStateProperty.PropertyId);

            Assert.IsInstanceOf <string>(readyStateValue);

            // By default, UIAControls.exe launches in not-ready state
            Assert.AreEqual("Not Ready", readyStateValue);
        }
        /// <summary>
        /// Adds the value of the ClickablePoint property to the A11yElement's Properties dictionary
        /// </summary>
        /// <remarks>
        /// Requesting the clickable point property in Edge can cause a crash,
        /// so the clickable point property is not initially populated by <see cref="DesktopElementExtensionMethods.PopulatePropertiesAndPatternsFromCache(A11yElement)"/>.
        /// </remarks>
        private static void InitClickablePointProperty(this A11yElement a11yElement, IUIAutomationElement uiaElement)
        {
            if (a11yElement.IsEdgeElement())
            {
                return;
            }

            int id = PropertyType.UIA_ClickablePointPropertyId;

            double[] clickablePoint = uiaElement.GetCurrentPropertyValue(id);
            if (clickablePoint == null)
            {
                return;
            }

            string name = A11yAutomation.UIAutomationObject.GetPropertyProgrammaticName(id);

            var prop = new A11yProperty
            {
                Id    = id,
                Name  = name,
                Value = new Point((int)clickablePoint[0], (int)clickablePoint[1])
            };

            a11yElement.Properties.Add(id, prop);
        }
Esempio n. 3
0
        /// <summary>
        /// Get Property value safely
        /// </summary>
        /// <param name="element"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        private static dynamic GetPropertyValue(IUIAutomationElement element, int id)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            dynamic value = null;

            try
            {
                value = element.GetCurrentPropertyValue(id);
                if (id == PropertyType.UIA_LabeledByPropertyId && value != null)
                {
                    value = GetHeaderOfLabelBy(value);
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception e)
            {
                e.ReportException();
                value = null;
            }
#pragma warning restore CA1031 // Do not catch general exception types

            return(value);
        }
Esempio n. 4
0
        public void Native_GettingPropertyValueByIdWithoutPatternInterfaceWorks()
        {
            CaretPositionPattern.Initialize();
            NSetTextAndSelection("abcd", 1, 2);
            var nSelStart = _nAdvancedTextBoxElement.GetCurrentPropertyValue(CaretPositionPattern.SelectionStartProperty.Id);

            Assert.AreEqual(1, nSelStart);
        }
Esempio n. 5
0
        public string GetAutomationId()
        {
            object obj;

            pElement.GetCurrentPropertyValue(UIA_AutomationIdPropertyId, out obj);
            return(obj.ToString());
        }
        private static string SimpleControlTypeName(IUIAutomationElement element)
        {
            var type = ControlType.LookupById(
                (int)element.GetCurrentPropertyValue(
                    AutomationElementIdentifiers.ControlTypeProperty.Id
                    )
                );

            return(type?.LocalizedControlType);
        }
Esempio n. 7
0
 public string GetAutomationId()
 {
     try {
         object obj;
         pElement.GetCurrentPropertyValue(UIA_AutomationIdPropertyId, out obj);
         return(obj.ToString());
     }
     catch (COMException) {
         return("");
     }
 }
        private void AutomationTree_TargetUpdated(object sender, DataTransferEventArgs e)
        {
            //IUIAutomationCondition uIAutomationCondition = new IUIAutomationCondition();
            CUIAutomation8            cUIAutomation8 = new CUIAutomation8();
            IUIAutomationElementArray rootChildrens  = cUIAutomation8.GetRootElement().FindAll(TreeScope.TreeScope_Children, cUIAutomation8.CreateTrueCondition());
            TreeViewItem tree = new TreeViewItem();

            tree.Header = cUIAutomation8.GetRootElement().GetCurrentPropertyValue(30005);
            //  IUIAutomationTreeWalker uIAutomationTreeWalker;
            // uIAutomationTreeWalker.
            for (int i = 0; i < rootChildrens.Length; i++)
            {
                IUIAutomationElement children = rootChildrens.GetElement(i);
                tree.Items.Add(String.Format("{0}  {1}", children.GetCurrentPropertyValue(30005), children.CurrentLocalizedControlType));
            }
            automationTree.Items.Add(tree);
            //MessageBox.Show(rootElement.GetCurrentPropertyValue(30012));
        }
Esempio n. 9
0
        /// <summary>
        /// Get Property value safely
        /// </summary>
        /// <param name="element"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        private static dynamic GetPropertyValue(IUIAutomationElement element, int id)
        {
            dynamic value = null;

            try
            {
                value = element.GetCurrentPropertyValue(id);
                if (id == PropertyType.UIA_LabeledByPropertyId && value != null)
                {
                    value = GetHeaderOfLabelBy(value);
                }
            }
            catch
            {
                value = null;
            }

            return(value);
        }
        /// <summary>
        /// Get Property value safely
        /// </summary>
        /// <param name="element"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        private static dynamic GetPropertyValue(IUIAutomationElement element, int id)
        {
            dynamic value = null;

            try
            {
                dynamic temp = ShouldGetPropertyValueNoDefault(id)
                    ? element.GetCurrentPropertyValueEx(id, 1 /*true*/)
                    : element.GetCurrentPropertyValue(id);

                value = ConvertVariantAsNeeded(temp);
            }
            catch
            {
                value = null;
            }

            return(value);
        }
        /// <summary>
        /// Get Property value safely
        /// </summary>
        /// <param name="element"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        private static dynamic GetPropertyValue(IUIAutomationElement element, int id)
        {
            dynamic value = null;
            try
            {
                dynamic temp = ShouldGetPropertyValueNoDefault(id)
                    ? element.GetCurrentPropertyValueEx(id, 1 /*true*/)
                    : element.GetCurrentPropertyValue(id);

                value = ConvertVariantAsNeeded(temp);
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception e)
            {
                e.ReportException();
                value = null;
            }
#pragma warning restore CA1031 // Do not catch general exception types

            return value;
        }