コード例 #1
0
        public int CheckTextBoxText(AutomationElement TextBoxObj, string ExpectedText, int TerminateStatus, string TBName)
        {
            Logger NewLogObj   = new Logger();
            string LogFilePath = NewLogObj.GetLogFilePath();

            NewLogObj.WriteLogFile(LogFilePath, "CheckTextBoxText", "info");
            NewLogObj.WriteLogFile(LogFilePath, "==================", "info");
            NewLogObj.WriteLogFile(LogFilePath, "Checking " + TBName + " textbox for text " + ExpectedText, "info");
            AutomationElementIdentity GuiObj = new AutomationElementIdentity();
            string ActaulText = GuiObj.GetTextBoxText(TextBoxObj, TBName, 0, LogFilePath);

            NewLogObj.WriteLogFile(LogFilePath, "ActaulText on " + TBName + "  " + ActaulText, "info");
            if (ActaulText != null)
            {
                if (string.Compare(ActaulText, ExpectedText) == 0)
                {
                    NewLogObj.WriteLogFile(LogFilePath, "ExpectedText found", "info");
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                NewLogObj.WriteLogFile(TBName, "Textbox value is null", "info");
                return(0);
            }

            return(0);
        }
コード例 #2
0
        public AutomationElement TypeInXenCenterSearchBox(AutomationElement XenCenterObj, string TextToType, int TerminateStatus, string LogFilePath)
        {
            Logger NewLogObj = new Logger();

            NewLogObj.WriteLogFile(LogFilePath, "TypeInXenCenterSearchBox", "info");
            NewLogObj.WriteLogFile(LogFilePath, "=============================", "info");

            try
            {
                AutomationElementIdentity GuiObj = new AutomationElementIdentity();
                PropertyCondition         WindowReturnCondition  = GuiObj.SetPropertyCondition("AutomationIdProperty", "TreeSearchBox", 1, LogFilePath);
                AutomationElement         SearchDialogObj        = GuiObj.FindAutomationElement(XenCenterObj, WindowReturnCondition, TreeScope.Descendants, "Search Box", 1, LogFilePath);
                PropertyCondition         TextBoxReturnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "textBox1", 1, LogFilePath);
                AutomationElement         SearchTextDialogObj    = GuiObj.FindAutomationElement(SearchDialogObj, TextBoxReturnCondition, TreeScope.Descendants, "Search Box", 1, LogFilePath);
                GuiObj.SetTextBoxText(SearchTextDialogObj, TextToType, "Search Box", 1, LogFilePath);
                string TextSet = GuiObj.GetTextBoxText(SearchTextDialogObj, "Search Box Text", 1, LogFilePath);
                //MbUnit.Framework.Assert.AreEqual(TextToType, TextSet);
                return(SearchDialogObj);
            }
            catch (Exception Ex)
            {
                NewLogObj.WriteLogFile(LogFilePath, "Exception at TypeInXenCenterSearchBox" + Ex.ToString(), "fail");
                if (TerminateStatus == 1)
                {
                    NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info");

                    NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from TypeInXenCenterSearchBox as main menunot found**", "fail");

                    FileOperations FileObj = new FileOperations();
                    FileObj.ExitTestEnvironment();
                    return(null);
                }
                else
                {
                    NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info");
                    return(null);
                }
            }
        }