예제 #1
0
 //**********************************************************************
 /// <summary>
 /// Close the test appliction
 /// </summary>
 public static void closeApp(int processId)
 {
     try
     {
         Host.Local.CloseApplication(processId);
     }
     catch (Exception e)
     {
         LxLog.Info("Error", e.Message.ToString());
     }
 }
예제 #2
0
        //**********************************************************************
        /// <summary>
        /// Map the action and call executeCommand to run script's steps.
        /// </summary>
        public static bool performScripts(ArrayList stepList)
        {
            LxSetup mainOp = LxSetup.getInstance();

            // Map action
            m_ActionMap.Clear();
            m_ActionMap.Add("InputKeys", new object[] { "PressKeys", "1" });
            m_ActionMap.Add("Click", new object[] { "Click", "0" });
            m_ActionMap.Add("Set", new object[] { "Check", "0" });
            m_ActionMap.Add("Clear", new object[] { "Uncheck", "0" });
            // m_ActionMap.Add("UnverifiedClickTab", new object[] {"Click","0"});
            m_ActionMap.Add("DoubleClick", new object[] { "DoubleClick", "0" });
            m_ActionMap.Add("Collapse", new object[] { "CollapseAll", "0" });
            m_ActionMap.Add("Expand", new object[] { "ExpandAll", "0" });
            m_ActionMap.Add("Select", new object[] { "SelectedItemText", "S1" });
            m_ActionMap.Add("CellContentClick", new object[] { "Click", "S2" });
            m_ActionMap.Add("SetTextValue", new object[] { "PressKeys", "S3" });
            m_ActionMap.Add("ClickItem", new object[] { "Click", "S4" });
            m_ActionMap.Add("VerifyToolTips", new object[] { "MoveTo", "S5" });
            m_ActionMap.Add("VerifyContains", new object[] { "Verify", "S6" });
            m_ActionMap.Add("VerifyNotContains", new object[] { "Verify", "S7" });
            m_ActionMap.Add("MoveTo", new object[] { "MoveTo", "S8" });
            m_ActionMap.Add("ClickCell", new object[] { "Click", "S9" });
            m_ActionMap.Add("DoubleClickItem", new object[] { "DoubleClick", "S10" });
            m_ActionMap.Add("RightClick", new object[] { "RightClick", "S11" });

            // Run the item in stepList
            foreach (LxScriptItem item in stepList)
            {
                bool resultFlag = true;
                try
                {
                    resultFlag = executeCommand(item);
                }
                catch (Exception e)
                {
                    resultFlag = false;
                    LxLog.Error("Error", e.Message.ToString());
                }

                // Log each step is pass or not
                mainOp.opXls.writeCell(Convert.ToInt32(item.m_Index) + 1, 14, resultFlag == true?"Pass":"******");
                LxLog.Info("Info", item.m_Index + " " + item.m_Component + " " + item.m_Action + " " + (resultFlag == true?"Success":"Failure"));
//				if(resultFlag == false)
//				{
//					return false;
//				}
            }
            return(true);
        }
예제 #3
0
        //**********************************************************************
        /// <summary>
        /// Map the action and call executeCommand to run script's steps.
        /// </summary>
        public static bool performScripts(ArrayList stepList)
        {
            LxSetup mainOp = LxSetup.getInstance();

            // Map action
            m_ActionMap.Clear();
            m_ActionMap.Add("InputKeys", new object[] { "PressKeys", "1" });
            m_ActionMap.Add("Click", new object[] { "Click", "0" });
            m_ActionMap.Add("Set", new object[] { "Check", "0" });
            m_ActionMap.Add("Clear", new object[] { "Uncheck", "0" });
            // m_ActionMap.Add("UnverifiedClickTab", new object[] {"Click","0"});
            m_ActionMap.Add("DoubleClick", new object[] { "DoubleClick", "0" });
            m_ActionMap.Add("Collapse", new object[] { "CollapseAll", "0" });
            m_ActionMap.Add("Expand", new object[] { "ExpandAll", "0" });
            m_ActionMap.Add("Select", new object[] { "SelectedItemText", "S1" });
            m_ActionMap.Add("CellContentClick", new object[] { "Click", "S2" });
            m_ActionMap.Add("SetTextValue", new object[] { "PressKeys", "S3" });
            m_ActionMap.Add("ClickItem", new object[] { "Click", "S4" });
            m_ActionMap.Add("VerifyToolTips", new object[] { "MoveTo", "S5" });
            m_ActionMap.Add("VerifyContains", new object[] { "Verify", "S6" });
            m_ActionMap.Add("VerifyNotContains", new object[] { "Verify", "S7" });
            m_ActionMap.Add("MoveTo", new object[] { "MoveTo", "S8" });
            m_ActionMap.Add("ClickCell", new object[] { "Click", "S9" });
            m_ActionMap.Add("DoubleClickItem", new object[] { "DoubleClick", "S10" });
            m_ActionMap.Add("RightClick", new object[] { "RightClick", "S11" });
            m_ActionMap.Add("InputCell", new object[] { "Click", "S12" });
            m_ActionMap.Add("ClickLocation", new object[] { "Click", "S13" });

            // Run the item in stepList
            // If wrongCount =3, it means that the command fails three times continuously.
            int    wrongTime  = 3;
            int    wrongCount = 0;
            string groupName  = "TryToRunTimes";
            string key        = "Try_Times";

            wrongTime = int.Parse(myparseToValue(groupName, key));
            //        MessageBox.Show("wrong Time ="+wrongTime);


            bool finalResult = true;

            foreach (LxScriptItem item in stepList)
            {
                bool resultFlag = true;
                try
                {
                    resultFlag = executeCommand(item);
                    wrongCount = 0;
                }
                catch (Exception e)
                {
                    wrongCount++;
                    resultFlag  = false;
                    finalResult = false;
                    LxLog.Error("Error", e.Message.ToString());
                }

                // Log each step is pass or not
                mainOp.opXls.writeCell(Convert.ToInt32(item.m_Index) + 1, 14, resultFlag == true?"Pass":"******");
                LxLog.Info("Info", item.m_Index + " " + item.m_Component + " " + item.m_Action + " " + (resultFlag == true?"Success":"Failure"));

                //If this script fails three times continuously, break this execution.
                if (wrongCount == wrongTime)
                {
                    break;
                }
            }

            return(finalResult);
        }
예제 #4
0
        //**********************************************************************
        /// <summary>
        /// Before excute, verify pre-condition.
        /// </summary>
        public void VerifyCondition()
        {
            //b_License=true, license is necessary;b_License=false, license is unnecessary;
            //b_Register=true, Register is necessary;b_Register=false, Register is unnecessary;
            //b_Device=true, many more devices are necessary;b_Device=false, many more devices are unnecessary;
            //b_Alarm=true, Alarm is necessary;b_Alarm=false, Alarm is unnecessary;
            bool b_License  = getLicenseCP();
            bool b_Register = getRegisterCP();
            bool b_Device   = getDeviceCP();
            bool b_Alarm    = getAlarmCP();

            //Login
            NformRepository repo = NformRepository.Instance;

            repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Username.PressKeys(m_strUserName);
            repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Password.PressKeys(m_stPassword);
            repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.ServerCombo.PressKeys(m_strServerName);
            repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Login.Click();
            Delay.Milliseconds(3000);

            if (repo.NFormApp.LicensesWindow.FormReminder.NoInfo.Exists())
            {
                repo.NFormApp.LicensesWindow.FormReminder.No.Click("53;10");
            }

            if (repo.NFormApp.LogintoLiebertNformWindow.FormEvaluation_Period_Expiration.OKInfo.Exists())
            {
                repo.NFormApp.LogintoLiebertNformWindow.FormEvaluation_Period_Expiration.OK.Click();
            }


            //Verify the license status
            repo.NFormApp.NformG2Window.FormMain.Configure.Click();
            repo.NFormApp.NformG2Window.FormMain.Licenses.Click();
            int license_count = repo.NFormApp.LicensesWindow.FormLicenses.LicenseList.Items.Count;

            try
            {
                if (license_count != 0)
                {
                    Validate.AreEqual(true, b_License);
                }
                else
                {
                    Validate.AreEqual(false, b_License);
                }
            }
            catch (Exception ex)
            {
                LxLog.Info("LicenseNotReady", ex.StackTrace.ToString());
            }

            repo.NFormApp.LicensesWindow.FormLicenses.Close.Click();
            Delay.Milliseconds(1000);

            //Verify the Register status
            repo.NFormApp.NformG2Window.FormMain.Help.Click();
            repo.NFormApp.NformG2Window.FormMain.About_Liebert_Nform.Click();
            repo.NFormApp.Help.FormAbout_LiebertR_Nform.TabRegistration.Click();
            bool unregister_flag = repo.NFormApp.Help.FormAbout_LiebertR_Nform.RegistrationDscr.TextValue.Equals("Software assurance: Unregistered");

            try
            {
                if (unregister_flag == true)
                {
                    Validate.AreEqual(false, b_Register);
                }
                else
                {
                    Validate.AreEqual(true, b_Register);
                }
            }
            catch (Exception ex)
            {
                LxLog.Info("RegisterNotReady", ex.StackTrace.ToString());
            }

            repo.NFormApp.Help.FormAbout_LiebertR_Nform.OK.Click();
            Delay.Milliseconds(1000);

            //Verify the Device status
            repo.NFormApp.NformG2Window.FormMain.Configure.Click();
            repo.NFormApp.NformG2Window.FormMain.Devices.Click();
            int device_count = repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Managed_device_table.Rows.Count;

            try
            {
                if (device_count > 1)
                {
                    Validate.AreEqual(true, b_Device);
                }
                else
                {
                    Validate.AreEqual(false, b_Device);
                }
            }
            catch (Exception ex)
            {
                LxLog.Info("DeviceNotReady", ex.StackTrace.ToString());
            }

            repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Close.Click();
            Delay.Milliseconds(1000);

            //Verify the Alarm status
            repo.NFormApp.NformG2Window.FormMain.Navigate.Click();
            repo.NFormApp.NformG2Window.FormMain.Alarms.Click();
            int alarm_count = repo.NFormApp.NformG2Window.FormMain.All_alarms_table.Rows.Count;

            try
            {
                if (alarm_count != 0)
                {
                    Validate.AreEqual(true, b_Alarm);
                }
                else
                {
                    Validate.AreEqual(false, b_Alarm);
                }
            }
            catch (Exception ex)
            {
                LxLog.Info("AlarmNotReady", ex.StackTrace.ToString());
            }
            Delay.Milliseconds(1000);

            //Set Visual alert in oder to avoid input missing.
            repo.NFormApp.NformG2Window.FormMain.Configure.Click();
            repo.NFormApp.NformG2Window.FormMain.User_Options.Click();
            repo.NFormApp.UserOptionsWindow.FormUser_Options.Visual_alerts.Click();
            repo.NFormApp.UserOptionsWindow.FormUser_Options.Bring_app_to_foreground.Uncheck();
            repo.NFormApp.UserOptionsWindow.FormUser_Options.Bring_app_to_foreground.Check();
            repo.NFormApp.UserOptionsWindow.FormUser_Options.Bring_app_to_foreground.Uncheck();
            repo.NFormApp.UserOptionsWindow.FormUser_Options.OK.Click();

            repo.NFormApp.NformG2Window.FormMain.Application.Click();
            repo.NFormApp.NformG2Window.FormMain.Login_As.Click();
            Delay.Milliseconds(1000);
        }
예제 #5
0
        /// <summary>
        /// Read the application path from scripts and run
        /// </summary>
        public void runApp()
        {
            if (!File.Exists(m_strExcelDirve))
            {
                runOverOneCase(getTestCaseName());
                throw new Ranorex.ElementNotFoundException("The file " + m_strExcelDirve + " not found", null);
            }
            opXls = new LxXlsOper();
            opXls.open(m_strExcelDirve);
            m_strApplicationName = opXls.readCell(2, 2);
            Console.WriteLine(m_strApplicationName);

            m_iRowNum = Convert.ToInt16(opXls.readCell(7, 2));

            m_strPrecondition = opXls.readCell(23, 2);


            string runningRange = opXls.readCell(8, 2);
            Regex  rex          = new Regex("[0-9]+");


            if (runningRange == "" || runningRange.IndexOf("a") != -1)
            {
                m_iRowStart = 1;
                m_iRowEnd   = m_iRowNum;
            }
            else
            {
                string[] range = runningRange.Split('-');
                m_iRowStart = Convert.ToInt16(range[0]);
                if (runningRange.IndexOf("-") == -1)
                {
                    m_iRowEnd = m_iRowNum;
                }
                else
                {
                    m_iRowEnd = Convert.ToInt16(range[1]);
                }
            }

            if (m_iRowStart == 1 && m_strApplicationName != "")
            {
                m_iProcessId = Host.Local.RunApplication(parseToValue(m_strApplicationName));
            }
            else
            {
                m_iProcessId = 0;
            }

            //Excute Precondition script to verify the Precondtion.
            try
            {
                if (!(m_strPrecondition.Trim().Equals("")))
                {
                    VerifyCondition();
                }
            }
            catch (Exception e)
            {
                LxLog.Error("Error", "The Precondition is not ready because: " + e.Message.ToString());
                return;
            }
        }