Esempio n. 1
0
        private static void RecordElements(AutomationElement currentElement, string parentName = "Main")
        {
            if (currentElement == null)
            {
                return;
            }

            var elementName = parentName + "-" + currentElement.Current.AutomationId;

            var elementChildMap       = MapAllControls(currentElement);
            var elementProperties     = ProcessElement(currentElement);
            var distinctChildElements = elementChildMap.Select(c => c.Item3).Distinct().ToList();

            var buildFileContent = new List <Tuple <string, string, string> >();

            buildFileContent.AddRange(DocumentHelper.AddHeaderFooter(elementChildMap, "Children"));
            buildFileContent.AddRange(DocumentHelper.AddHeaderFooter(elementProperties, "Properties"));
            DocumentHelper.CreateFileForAutomationElement(elementName, buildFileContent);

            foreach (var distinctChild in distinctChildElements)
            {
                if (!DocumentHelper.IsFileEnteredInIndex(elementName + distinctChild))
                {
                    var child = currentElement.FindChildById(distinctChild);
                    //Recursive to reach all child elements currently in view
                    if (child != null)
                    {
                        RecordElements(child, elementName);
                    }
                }
                else
                {
                    continue;
                }
            }
        }