Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

Automation

$
0
0

I have to find all the controls in a specific url and print the name property of those controls.

                                                   

  [TestMethod]
        public void CodedUITestMethod1()
        {
            Console.WriteLine("inside method1");
            BrowserWindow browser = BrowserWindow.Launch(new Uri("https://technet.microsoft.com/en-us/"));
            browser.Maximized = true;

            Playback.Wait(10000);


            PropertyCondition autoid =new PropertyCondition(AutomationElement.AutomationIdProperty, "megabladeMainMenu");
            AutomationElement control = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, autoid);

            Properties(control);
        }


            private void Properties(AutomationElement element)
            {
            Console.WriteLine("inside method2");
            if (element == null)
            {
                Console.WriteLine("null");
                return;
            }

              AutomationElement elementNode = TreeWalker.ControlViewWalker.GetFirstChild(element);

                while (elementNode != null)
                {

                    string controlName = (elementNode.Current.Name == "") ? "Unnamed Control" : elementNode.Current.Name;
                    string autoIdName = (elementNode.Current.AutomationId == "") ? "No AutomationID" : elementNode.Current.AutomationId;
                    Console.WriteLine("Name Property : " + controlName);
                    Console.WriteLine("automation Id : " + autoIdName);
                } 

            elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode);
            Properties(elementNode);
        }

Tried it this way but the automation element being passed is recognized as null.Can I get any suggestions regarding this problem.


Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>