public IEnumerable <UiExecutionEntry> GetExecutions()
        {
            UIItemCollection controls = ContentPanel.Items;
            int promptIndex           = FindPromptIndex(controls, controls.Count - 1);
            int nextPromptIndex       = controls.Count;

            while (promptIndex >= 0)
            {
                CustomUIItem      codeInput         = controls[promptIndex + 1] as CustomUIItem;
                AutomationElement automationElement = codeInput?.AutomationElement;
                var valuePattern = automationElement?.GetSupportedPatterns()?.FirstOrDefault(p => p.ProgrammaticName.Contains("Value"));
                var value        = automationElement?.GetCurrentPattern(valuePattern) as ValuePattern;

                string code   = value?.Current.Value;
                string prompt = (controls[promptIndex] as WPFLabel)?.Text;

                IUIItem[] result = new IUIItem[nextPromptIndex - promptIndex - 2];
                for (int i = promptIndex + 2, k = 0; i < nextPromptIndex; i++, k++)
                {
                    result[k] = controls[i];
                }

                yield return(new UiExecutionEntry()
                {
                    Code = code,
                    Prompt = prompt,
                    Result = result,
                });

                nextPromptIndex = promptIndex;
                promptIndex     = FindPromptIndex(controls, promptIndex - 1);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Retrieves a White element using RawElementBasedSearch with the given MaxElementSearchDepth, which can be much faster than a normal search for large control trees.
 /// </summary>
 public static T RawGet <T>(this CustomUIItem item, string id, int searchDepth = 3) where T : UIItem
 {
     return(RawGet <T>(item.AutomationElement, SearchCriteria.ByAutomationId(id), searchDepth));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Retrieves a White element using RawElementBasedSearch with the given MaxElementSearchDepth, which can be much faster than a normal search for large control trees.
 /// </summary>
 public static T RawGet <T>(this CustomUIItem item, SearchCriteria criteria, int searchDepth = 3) where T : UIItem
 {
     return(RawGet <T>(item.AutomationElement, criteria, searchDepth));
 }