Beispiel #1
0
        /// <summary>
        /// Handles the UIA version of The extended interface. event
        /// </summary>
        /// <param name="control">The UI Automation element</param>
        private static void UiaInvoke(BaseProdControl control)
        {
            AutomationEventVerifier.Register(new EventRegistrationMessage(control, InvokePattern.InvokedEvent));
            LogController.ReceiveLogMessage(new LogMessage(CLICK_MSG + control.UIAElement.Current.Name));

            InvokePatternHelper.Invoke(control.UIAElement);
        }
        /// <summary>
        ///     Clicks this instance.
        /// </summary>
        public void Click()
        {
            LogText = "Click Verified";

            RegisterEvent(InvokePattern.InvokedEvent);
            InvokePatternHelper.Invoke(UIAElement);
        }
 /// <summary>
 ///     Finds an AutomationElement in a list.
 /// </summary>
 /// <param name = "item">The item to search for.</param>
 /// <param name = "itemPath">The 'path' to the menu item.</param>
 private static void FindItemStatic(AutomationElement item, Collection <string> itemPath)
 {
     /* Loop through supplied menu path */
     for (int i = 1; i < itemPath.Count; i++)
     {
         try
         {
             /* Get next item */
             AutomationElement ael = item.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, itemPath[i], PropertyConditionFlags.IgnoreCase));
             /* Expand next item */
             ExpandCollapseHelper.Expand(ael);
             ael.SetFocus();
             InvokePatternHelper.Invoke(ael);
         }
         catch (InvalidOperationException err)
         {
             throw new ProdOperationException(err.Message, err);
         }
         catch (ElementNotAvailableException err)
         {
             throw new ProdOperationException(err.Message, err);
         }
     }
     return;
 }
Beispiel #4
0
 /// <summary>
 /// Performs a "Click" on the specified static ProdButton
 /// </summary>
 /// <param name="controlHandle">NativeWindowHandle of the target control</param>
 /// <exception cref="ProdOperationException">Examine inner exception</exception>
 /// <remarks>
 /// This overload is invalid for WPF controls
 /// </remarks>
 public static void ButtonClick(IntPtr controlHandle)
 {
     try
     {
         AutomationElement control = CommonUIAPatternHelpers.Prologue(InvokePattern.Pattern, controlHandle);
         StaticEvents.RegisterEvent(InvokePattern.InvokedEvent, control);
         InvokePatternHelper.Invoke(control);
         LogController.ReceiveLogMessage(new LogMessage(control.Current.Name));
     }
     catch (InvalidOperationException err)
     {
         throw new ProdOperationException(err.Message, err);
     }
     catch (ElementNotAvailableException err)
     {
         throw new ProdOperationException(err.Message, err);
     }
     catch (ArgumentException err)
     {
         throw new ProdOperationException(err.Message, err);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Expands the menu item.
        /// </summary>
        /// <param name="menuItems">The menu items.</param>
        /// <param name="itemPath">The item path.</param>
        private static void ExpandMenuItem(AutomationElementCollection menuItems, string[] itemPath)
        {
            foreach (AutomationElement item in menuItems)
            {
                /* Expand top menu */
                try
                {
                    string name = item.Current.Name;
                    if (string.Compare(name, itemPath[_ctr], true, CultureInfo.CurrentCulture) != 0)
                    {
                        continue;
                    }

                    if (CommonUIAPatternHelpers.CheckPatternSupport(ExpandCollapsePattern.Pattern, item) != null)
                    {
                        ExpandCollapseHelper.Expand(item);

                        AutomationElementCollection items = GetChildMenuItems(item);
                        _ctr++;
                        ExpandMenuItem(items, itemPath);
                    }

                    if (CommonUIAPatternHelpers.CheckPatternSupport(InvokePattern.Pattern, item) == null)
                    {
                        return;
                    }
                    InvokePatternHelper.Invoke(item);
                }
                catch (InvalidOperationException err)
                {
                    throw new ProdOperationException(err.Message, err);
                }
                catch (ElementNotAvailableException err)
                {
                    throw new ProdOperationException(err.Message, err);
                }
            }
        }