Example #1
0
        //**************************************************************************************************************************************************************
        public static void UIA_SetFocusOfFirstTextBox(AutomationElement uiaWindow, Window window)
        {
            try
            {
                PropertyCondition textCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text);
                AutomationElementCollection textBoxes = uiaWindow.FindAll(TreeScope.Descendants, textCondition);
                foreach (AutomationElement textBox in textBoxes)
                {
                    TestStack.White.UIItems.TextBox t = new TestStack.White.UIItems.TextBox(textBox, window.ActionListener);
                    t.Focus();
                    t.Click();
                    Thread.Sleep(int.Parse(Execution_Speed));
                    break;
                }

            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
        //**************************************************************************************************************************************************************

        public static void UIA_SetFocusOfFirstTextBox(AutomationElement uiaWindow, Window window)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);
            try
            {
                PropertyCondition textCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text);
                AutomationElementCollection textBoxes = uiaWindow.FindAll(TreeScope.Descendants, textCondition);
                foreach (AutomationElement textBox in textBoxes)
                {
                    TestStack.White.UIItems.TextBox t = new TestStack.White.UIItems.TextBox(textBox, window.ActionListener);
                    t.Focus();
                    t.Click();
                    Thread.Sleep(int.Parse(Execution_Speed));
                    break;
                }
                Logger.logMessage("UIA_SetFocusOfFirstTextBox " + uiaWindow + "->" + window + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");

            }
            catch (Exception e)
            {
                Logger.logMessage("UIA_SetFocusOfFirstTextBox " + uiaWindow + "->" + window + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }